IndustryController.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. using Amazon.Runtime.Internal.Transform;
  2. using Hotline.Application.Snapshot;
  3. using Hotline.Caching.Interfaces;
  4. using Hotline.Configurations;
  5. using Hotline.Repository.SqlSugar.Extensions;
  6. using Hotline.Settings;
  7. using Hotline.Share.Dtos;
  8. using Hotline.Share.Dtos.Snapshot;
  9. using Hotline.Share.Tools;
  10. using Hotline.Snapshot;
  11. using Hotline.Snapshot.Interfaces;
  12. using Microsoft.AspNetCore.Mvc;
  13. using Microsoft.Extensions.Options;
  14. using SqlSugar;
  15. namespace Hotline.Api.Controllers.Snapshot;
  16. /// <summary>
  17. /// 随手拍行业管理接口
  18. /// </summary>
  19. public class IndustryController : BaseController
  20. {
  21. private readonly IIndustryRepository _industryRepository;
  22. private readonly ISystemDicDataCacheManager _systemDicDataCacheManager;
  23. private readonly IIndustryApplication _industryApplication;
  24. private readonly ISystemAreaDomainService _systemAreaDomainService;
  25. private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
  26. public IndustryController(IIndustryRepository industryRepository, IIndustryApplication industryApplication, ISystemDicDataCacheManager systemDicDataCacheManager, ISystemAreaDomainService systemAreaDomainService, IOptionsSnapshot<AppConfiguration> appOptions)
  27. {
  28. _industryRepository = industryRepository;
  29. _industryApplication = industryApplication;
  30. _systemDicDataCacheManager = systemDicDataCacheManager;
  31. _systemAreaDomainService = systemAreaDomainService;
  32. _appOptions = appOptions;
  33. }
  34. /// <summary>
  35. /// 添加行业页面基础数据
  36. /// </summary>
  37. /// <returns></returns>
  38. [HttpGet("basedata")]
  39. public Dictionary<string, object> GetBaseData()
  40. {
  41. return new Dictionary<string, object>
  42. {
  43. { "department", _systemDicDataCacheManager.SnapshotDepartment },
  44. { "acceptType", _systemDicDataCacheManager.AcceptType},
  45. { "bulletinType", _systemDicDataCacheManager.SnapshotBulletinType}
  46. };
  47. }
  48. /// <summary>
  49. /// 新增行业
  50. /// </summary>
  51. /// <returns></returns>
  52. [HttpPost]
  53. public async Task<string> AddIndustry([FromBody] AddIndustryDto dto)
  54. => await _industryApplication.AddIndustryAsync(dto, HttpContext.RequestAborted);
  55. /// <summary>
  56. /// 行业详情
  57. /// </summary>
  58. /// <param name="id"></param>
  59. /// <returns></returns>
  60. [HttpGet("{id}")]
  61. public async Task<IndustryDetailOutDto> GetIndustryDetailAsync(string id)
  62. => await _industryApplication.GetIndustryDetailAsync(id);
  63. /// <summary>
  64. /// 获取行业集合
  65. /// </summary>
  66. /// <returns></returns>
  67. [HttpGet("industry")]
  68. public async Task<PagedDto<IndustryItemsOutDto>> GetIndustryAsync([FromQuery] IndustryListInDto dto)
  69. => (await _industryApplication.GetIndustres(dto).ToPagedListAsync(dto, HttpContext.RequestAborted)).ToPaged();
  70. /// <summary>
  71. /// 修改行业
  72. /// </summary>
  73. /// <param name="dto"></param>
  74. /// <returns></returns>
  75. [HttpPut]
  76. public async Task UpdateIndustry([FromBody] UpdateIndustryInDto dto)
  77. => await _industryApplication.UpdateIndustryAsync(dto, HttpContext.RequestAborted);
  78. #region 行业线索
  79. /// <summary>
  80. /// 行业线索集合
  81. /// </summary>
  82. /// <param name="dto"></param>
  83. /// <returns></returns>
  84. [HttpGet("case")]
  85. public async Task<PagedDto<IndustryCaseItemOutDto>> GetIndustryCaseItemAsync([FromQuery] IndustryCaseItemInDto dto)
  86. => (await _industryApplication.GetIndustryCaseItems(dto).ToPagedListAsync(dto, HttpContext.RequestAborted)).ToPaged();
  87. /// <summary>
  88. /// 添加行业线索
  89. /// </summary>
  90. /// <param name="dto"></param>
  91. /// <returns></returns>
  92. [HttpPost("case")]
  93. public async Task AddIndustryCaseAsync([FromBody] AddIndustryCaseDto dto)
  94. => await _industryApplication.AddIndustryCaseAsync(dto);
  95. /// <summary>
  96. /// 更新行业线索
  97. /// </summary>
  98. /// <param name="dto"></param>
  99. /// <returns></returns>
  100. [HttpPut("case")]
  101. public async Task UpdateIndustryCaseAsync([FromBody]UpdateIndustryCaseDto dto)
  102. => await _industryApplication.UpdateIndustryCaseAsync(dto);
  103. /// <summary>
  104. /// 获取行业线索详情
  105. /// </summary>
  106. /// <param name="id"></param>
  107. /// <returns></returns>
  108. [HttpGet("case/{id}")]
  109. public async Task<IndustryCase> GetIndustryCaseDetailAsync(string id)
  110. => await _industryApplication.GetIndustryCaseAsync(id);
  111. /// <summary>
  112. /// 页面基础数据
  113. /// </summary>
  114. /// <returns></returns>
  115. [HttpGet("case/database")]
  116. public async Task<Dictionary<string, object>> GetIndustryCaseDataBaseAsync()
  117. {
  118. var items = await _industryRepository.Queryable()
  119. .Select(m => new { m.Id, m.Name })
  120. .ToListAsync();
  121. return new Dictionary<string, object>
  122. {
  123. { "industry", items }
  124. };
  125. }
  126. #endregion
  127. #region 行业短信模板
  128. /// <summary>
  129. /// 行业短信模板集合
  130. /// </summary>
  131. /// <param name="dto"></param>
  132. /// <returns></returns>
  133. [HttpGet("sms_template")]
  134. public async Task<PagedDto<SnapshotSMSTemplateItemsOutDto>> GetSmsTemplateItemsAsync([FromQuery]SnapshotSMSTemplateItemsInDto dto)
  135. => (await _industryApplication.GetSMSTemplates(dto).ToPagedListAsync(dto, HttpContext.RequestAborted)).ToPaged();
  136. /// <summary>
  137. /// 添加行业短信模板
  138. /// </summary>
  139. /// <param name="dto"></param>
  140. /// <returns></returns>
  141. [HttpPost("sms_template")]
  142. public async Task AddSmsTemplateAsync([FromBody] AddSnapshotSMSTemplateInDto dto)
  143. => await _industryApplication.AddSMSTemplateAsync(dto);
  144. /// <summary>
  145. /// 修改行业短信模板
  146. /// </summary>
  147. /// <param name="dto"></param>
  148. /// <returns></returns>
  149. [HttpPut("sms_template")]
  150. public async Task UpdateSmsTemplateAsync([FromBody] UpdateSnapshotSMSTemplateInDto dto)
  151. => await _industryApplication.UpdateSMSTemplateAsync(dto);
  152. /// <summary>
  153. /// 短信详情
  154. /// </summary>
  155. /// <param name="id"></param>
  156. /// <returns></returns>
  157. [HttpGet("sms_template/{id}")]
  158. public async Task<SnapshotSMSTemplateItemsOutDto> GetSMSTemplateDetailAsync(string id)
  159. => await _industryApplication.GetSMSTemplateDetailAsync(id);
  160. #endregion
  161. #region 区域从业人员
  162. /// <summary>
  163. /// 区域从业人员集合
  164. /// </summary>
  165. /// <returns></returns>
  166. [HttpGet("practitioner")]
  167. public async Task<PagedDto<PractitionerItemsOutDto>> GetPractitionerItemsAsync([FromQuery] PractitionerItemsInDto dto)
  168. => (await _industryApplication.GetPractitionerItemsAsync(dto).ToPagedListAsync(dto, HttpContext.RequestAborted)).ToPaged();
  169. /// <summary>
  170. /// 添加区域从业人员
  171. /// </summary>
  172. /// <param name="dto"></param>
  173. /// <returns></returns>
  174. [HttpPost("practitioner")]
  175. public async Task<string> AddPractitionerAsync([FromBody]AddPractitionerInDto dto)
  176. => await _industryApplication.AddPractitionerAsync(dto);
  177. /// <summary>
  178. /// 删除区域从业人员
  179. /// </summary>
  180. /// <param name="ids"></param>
  181. /// <returns></returns>
  182. [HttpDelete("practitioner")]
  183. public async Task DeletePractitionerAsync([FromBody]IList<string> ids)
  184. => await _industryApplication.DeletePractitionerAsync(ids);
  185. /// <summary>
  186. /// 修改区域从业人员
  187. /// </summary>
  188. /// <param name="dto"></param>
  189. /// <returns></returns>
  190. [HttpPut("practitioner")]
  191. public async Task UpdatePractitionerAsync(UpdatePractitionerInDto dto)
  192. => await _industryApplication.UpdatePractitionerAsync(dto);
  193. /// <summary>
  194. /// 从业人员详情
  195. /// </summary>
  196. /// <param name="id"></param>
  197. /// <returns></returns>
  198. [HttpGet("practitioner/{id}")]
  199. public async Task<PractitionerItemsOutDto> GetPractitionerAsync(string id)
  200. => await _industryApplication.GetPractitionerAsync(id);
  201. /// <summary>
  202. /// 添加从业人员基础数据
  203. /// </summary>
  204. /// <returns></returns>
  205. [HttpGet("practitioner/basedata")]
  206. public async Task<Dictionary<string, object>> GetPractitionerDataBaseAsync()
  207. {
  208. var parentId = "";
  209. if (_appOptions.Value.IsZiGong) parentId = _appOptions.Value.ZiGong.AreaCode;
  210. return new Dictionary<string, object>
  211. {
  212. { "area", await _systemAreaDomainService.GetAreaTree(parentId: parentId)}
  213. };
  214. }
  215. #endregion
  216. #region 志愿者
  217. /// <summary>
  218. /// 志愿者集合
  219. /// </summary>
  220. /// <param name="dto"></param>
  221. /// <returns></returns>
  222. [HttpGet("volunteer")]
  223. public async Task<PagedDto<VolunteerItemsOutDto>> GetVolunteerItemsAsync([FromQuery] VolunteerItemsInDto dto)
  224. => (await _industryApplication.GetVolunteerItemsAsync(dto).ToPagedListAsync(dto, HttpContext.RequestAborted)).ToPaged();
  225. /// <summary>
  226. /// 添加志愿者
  227. /// </summary>
  228. /// <param name="dto"></param>
  229. /// <returns></returns>
  230. [HttpPost("volunteer")]
  231. public async Task<string> AddVolunteerAsync([FromBody] AddVolunteerInDto dto)
  232. => await _industryApplication.AddVolunteerAsync(dto);
  233. /// <summary>
  234. /// 批量删除志愿者
  235. /// </summary>
  236. /// <param name="ids"></param>
  237. /// <returns></returns>
  238. [HttpDelete("volunteer")]
  239. public async Task DeleteVolunteerAsync([FromBody]IList<string> ids)
  240. => await _industryApplication.DeleteVolunteerAsync(ids);
  241. /// <summary>
  242. /// 志愿者详情
  243. /// </summary>
  244. /// <param name="id"></param>
  245. /// <returns></returns>
  246. [HttpGet("volunteer/{id}")]
  247. public async Task<Volunteer> GetVolunteerAsync(string id)
  248. => await _industryApplication.GetVolunteerAsync(id);
  249. /// <summary>
  250. /// 修改志愿者
  251. /// </summary>
  252. /// <param name="dto"></param>
  253. /// <returns></returns>
  254. [HttpPut("volunteer")]
  255. public async Task UpdateVolunteerAsync([FromBody]UpdateVolunteerInDto dto)
  256. => await _industryApplication.UpdateVolunteerAsync(dto);
  257. /// <summary>
  258. /// 志愿者上报集合
  259. /// </summary>
  260. /// <param name="dto"></param>
  261. /// <returns></returns>
  262. [HttpGet("volunteer/report")]
  263. public async Task<PagedDto<VolunteerReportItemsOutDto>> GetVolunteerReportItemsAsync([FromQuery]VolunteerReportItemsInDto dto)
  264. => (await _industryApplication.GetVolunteerReportItemsAsync(dto).ToPagedListAsync(dto)).ToPaged();
  265. #endregion
  266. }