IndustryController.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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. namespace Hotline.Api.Controllers.Snapshot;
  15. /// <summary>
  16. /// 随手拍行业管理接口
  17. /// </summary>
  18. public class IndustryController : BaseController
  19. {
  20. private readonly IIndustryRepository _industryRepository;
  21. private readonly ISystemDicDataCacheManager _systemDicDataCacheManager;
  22. private readonly IIndustryApplication _industryApplication;
  23. private readonly ISystemAreaDomainService _systemAreaDomainService;
  24. private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
  25. public IndustryController(IIndustryRepository industryRepository, IIndustryApplication industryApplication, ISystemDicDataCacheManager systemDicDataCacheManager, ISystemAreaDomainService systemAreaDomainService, IOptionsSnapshot<AppConfiguration> appOptions)
  26. {
  27. _industryRepository = industryRepository;
  28. _industryApplication = industryApplication;
  29. _systemDicDataCacheManager = systemDicDataCacheManager;
  30. _systemAreaDomainService = systemAreaDomainService;
  31. _appOptions = appOptions;
  32. }
  33. /// <summary>
  34. /// 添加行业页面基础数据
  35. /// </summary>
  36. /// <returns></returns>
  37. [HttpGet("basedata")]
  38. public Dictionary<string, object> GetBaseData()
  39. {
  40. return new Dictionary<string, object>
  41. {
  42. { "department", _systemDicDataCacheManager.SnapshotDepartment },
  43. { "acceptType", _systemDicDataCacheManager.AcceptType},
  44. { "bulletinType", _systemDicDataCacheManager.SnapshotBulletinType}
  45. };
  46. }
  47. /// <summary>
  48. /// 新增行业
  49. /// </summary>
  50. /// <returns></returns>
  51. [HttpPost]
  52. public async Task<string> AddIndustry([FromBody] AddIndustryDto dto)
  53. => await _industryApplication.AddIndustryAsync(dto, HttpContext.RequestAborted);
  54. /// <summary>
  55. /// 行业详情
  56. /// </summary>
  57. /// <param name="id"></param>
  58. /// <returns></returns>
  59. [HttpGet("{id}")]
  60. public async Task<IndustryDetailOutDto> GetIndustryDetailAsync(string id)
  61. => await _industryApplication.GetIndustryDetailAsync(id);
  62. /// <summary>
  63. /// 获取行业集合
  64. /// </summary>
  65. /// <returns></returns>
  66. [HttpGet("industry")]
  67. public async Task<PagedDto<IndustryItemsOutDto>> GetIndustryAsync([FromQuery] IndustryListInDto dto)
  68. => (await _industryApplication.GetIndustres(dto).ToPagedListAsync(dto, HttpContext.RequestAborted)).ToPaged();
  69. /// <summary>
  70. /// 修改行业
  71. /// </summary>
  72. /// <param name="dto"></param>
  73. /// <returns></returns>
  74. [HttpPut]
  75. public async Task UpdateIndustry([FromBody] UpdateIndustryInDto dto)
  76. => await _industryApplication.UpdateIndustryAsync(dto, HttpContext.RequestAborted);
  77. #region 行业线索
  78. /// <summary>
  79. /// 行业线索集合
  80. /// </summary>
  81. /// <param name="dto"></param>
  82. /// <returns></returns>
  83. [HttpGet("case")]
  84. public async Task<PagedDto<IndustryCaseItemOutDto>> GetIndustryCaseItemAsync([FromQuery] IndustryCaseItemInDto dto)
  85. => (await _industryApplication.GetIndustryCaseItems(dto).ToPagedListAsync(dto, HttpContext.RequestAborted)).ToPaged();
  86. /// <summary>
  87. /// 添加行业线索
  88. /// </summary>
  89. /// <param name="dto"></param>
  90. /// <returns></returns>
  91. [HttpPost("case")]
  92. public async Task AddIndustryCaseAsync([FromBody] AddIndustryCaseDto dto)
  93. => await _industryApplication.AddIndustryCaseAsync(dto);
  94. /// <summary>
  95. /// 更新行业线索
  96. /// </summary>
  97. /// <param name="dto"></param>
  98. /// <returns></returns>
  99. [HttpPut("case")]
  100. public async Task UpdateIndustryCaseAsync([FromBody]UpdateIndustryCaseDto dto)
  101. => await _industryApplication.UpdateIndustryCaseAsync(dto);
  102. /// <summary>
  103. /// 获取行业线索详情
  104. /// </summary>
  105. /// <param name="id"></param>
  106. /// <returns></returns>
  107. [HttpGet("case/{id}")]
  108. public async Task<IndustryCase> GetIndustryCaseDetailAsync(string id)
  109. => await _industryApplication.GetIndustryCaseAsync(id);
  110. /// <summary>
  111. /// 页面基础数据
  112. /// </summary>
  113. /// <returns></returns>
  114. [HttpGet("case/database")]
  115. public async Task<Dictionary<string, object>> GetIndustryCaseDataBaseAsync()
  116. {
  117. var items = await _industryRepository.Queryable()
  118. .Select(m => new { m.Id, m.Name })
  119. .ToListAsync();
  120. return new Dictionary<string, object>
  121. {
  122. { "industry", items }
  123. };
  124. }
  125. #endregion
  126. #region 行业短信模板
  127. /// <summary>
  128. /// 行业短信模板集合
  129. /// </summary>
  130. /// <param name="dto"></param>
  131. /// <returns></returns>
  132. [HttpGet("sms_template")]
  133. public async Task<PagedDto<SnapshotSMSTemplateItemsOutDto>> GetSmsTemplateItemsAsync([FromQuery]SnapshotSMSTemplateItemsInDto dto)
  134. => (await _industryApplication.GetSMSTemplates(dto).ToPagedListAsync(dto, HttpContext.RequestAborted)).ToPaged();
  135. /// <summary>
  136. /// 添加行业短信模板
  137. /// </summary>
  138. /// <param name="dto"></param>
  139. /// <returns></returns>
  140. [HttpPost("sms_template")]
  141. public async Task AddSmsTemplateAsync([FromBody] AddSnapshotSMSTemplateInDto dto)
  142. => await _industryApplication.AddSMSTemplateAsync(dto);
  143. /// <summary>
  144. /// 修改行业短信模板
  145. /// </summary>
  146. /// <param name="dto"></param>
  147. /// <returns></returns>
  148. [HttpPut("sms_template")]
  149. public async Task UpdateSmsTemplateAsync([FromBody] UpdateSnapshotSMSTemplateInDto dto)
  150. => await _industryApplication.UpdateSMSTemplateAsync(dto);
  151. /// <summary>
  152. /// 短信详情
  153. /// </summary>
  154. /// <param name="id"></param>
  155. /// <returns></returns>
  156. [HttpGet("sms_template/{id}")]
  157. public async Task<SnapshotSMSTemplateItemsOutDto> GetSMSTemplateDetailAsync(string id)
  158. => await _industryApplication.GetSMSTemplateDetailAsync(id);
  159. #endregion
  160. #region 区域从业人员
  161. /// <summary>
  162. /// 区域从业人员集合
  163. /// </summary>
  164. /// <returns></returns>
  165. [HttpGet("practitioner")]
  166. public async Task<PagedDto<PractitionerItemsOutDto>> GetPractitionerItemsAsync([FromQuery] PractitionerItemsInDto dto)
  167. => (await _industryApplication.GetPractitionerItemsAsync(dto).ToPagedListAsync(dto, HttpContext.RequestAborted)).ToPaged();
  168. /// <summary>
  169. /// 添加区域从业人员
  170. /// </summary>
  171. /// <param name="dto"></param>
  172. /// <returns></returns>
  173. [HttpPost("practitioner")]
  174. public async Task<string> AddPractitionerAsync([FromBody]AddBatchPractitionerInDto dto)
  175. => await _industryApplication.AddPractitionerAsync(dto);
  176. /// <summary>
  177. /// 删除区域从业人员
  178. /// </summary>
  179. /// <param name="id"></param>
  180. /// <returns></returns>
  181. [HttpDelete("practitioner")]
  182. public async Task DeletePractitionerAsync([FromBody]IList<string> ids)
  183. => await _industryApplication.DeletePractitionerAsync(ids);
  184. /// <summary>
  185. /// 从业人员详情
  186. /// </summary>
  187. /// <param name="id"></param>
  188. /// <returns></returns>
  189. [HttpGet("practitioner/{id}")]
  190. public async Task<PractitionerItemsOutDto> GetPractitionerAsync(string id)
  191. => await _industryApplication.GetPractitionerAsync(id);
  192. /// <summary>
  193. /// 添加从业人员基础数据
  194. /// </summary>
  195. /// <returns></returns>
  196. [HttpGet("practitioner/basedata")]
  197. public async Task<Dictionary<string, object>> GetPractitionerDataBaseAsync()
  198. {
  199. var parentId = "";
  200. if (_appOptions.Value.IsZiGong) parentId = _appOptions.Value.ZiGong.AreaCode;
  201. return new Dictionary<string, object>
  202. {
  203. { "area", await _systemAreaDomainService.GetAreaTree(parentId: parentId)}
  204. };
  205. }
  206. #endregion
  207. }