IndustryController.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using Amazon.Runtime.Internal.Transform;
  2. using Hotline.Application.Snapshot;
  3. using Hotline.Caching.Interfaces;
  4. using Hotline.Repository.SqlSugar.Extensions;
  5. using Hotline.Share.Dtos;
  6. using Hotline.Share.Dtos.Snapshot;
  7. using Hotline.Share.Tools;
  8. using Hotline.Snapshot.Interfaces;
  9. using Microsoft.AspNetCore.Mvc;
  10. namespace Hotline.Api.Controllers.Snapshot;
  11. /// <summary>
  12. /// 随手拍行业管理接口
  13. /// </summary>
  14. public class IndustryController : BaseController
  15. {
  16. private readonly IIndustryRepository _industryRepository;
  17. private readonly ISystemDicDataCacheManager _systemDicDataCacheManager;
  18. private readonly IIndustryApplication _industryApplication;
  19. public IndustryController(IIndustryRepository industryRepository, IIndustryApplication industryApplication, ISystemDicDataCacheManager systemDicDataCacheManager)
  20. {
  21. _industryRepository = industryRepository;
  22. _industryApplication = industryApplication;
  23. _systemDicDataCacheManager = systemDicDataCacheManager;
  24. }
  25. /// <summary>
  26. /// 添加行业页面基础数据
  27. /// </summary>
  28. /// <returns></returns>
  29. [HttpGet("basedata")]
  30. public Dictionary<string, object> GetBaseData()
  31. {
  32. return new Dictionary<string, object>
  33. {
  34. { "department", _systemDicDataCacheManager.SnapshotDepartment },
  35. { "acceptType", _systemDicDataCacheManager.AcceptType},
  36. { "bulletinType", _systemDicDataCacheManager.SnapshotBulletinType}
  37. };
  38. }
  39. /// <summary>
  40. /// 新增行业
  41. /// </summary>
  42. /// <returns></returns>
  43. [HttpPost]
  44. public async Task<string> AddIndustry([FromBody] AddIndustryDto dto)
  45. => await _industryApplication.AddIndustryAsync(dto, HttpContext.RequestAborted);
  46. /// <summary>
  47. /// 行业详情
  48. /// </summary>
  49. /// <param name="id"></param>
  50. /// <returns></returns>
  51. [HttpGet("{id}")]
  52. public async Task<IndustryDetailOutDto> GetIndustryDetailAsync(string id)
  53. => await _industryApplication.GetIndustryDetailAsync(id);
  54. /// <summary>
  55. /// 获取行业集合
  56. /// </summary>
  57. /// <returns></returns>
  58. [HttpGet("industry")]
  59. public async Task<PagedDto<IndustryItemsOutDto>> GetIndustryAsync([FromQuery] IndustryListInDto dto)
  60. => (await _industryApplication.GetIndustres(dto).ToPagedListAsync(dto, HttpContext.RequestAborted)).ToPaged();
  61. /// <summary>
  62. /// 修改行业
  63. /// </summary>
  64. /// <param name="dto"></param>
  65. /// <returns></returns>
  66. [HttpPut]
  67. public async Task UpdateIndustry([FromBody] UpdateIndustryInDto dto)
  68. => await _industryApplication.UpdateIndustryAsync(dto, HttpContext.RequestAborted);
  69. }