IndustryController.cs 11 KB

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