123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- using Amazon.Runtime.Internal.Transform;
- using Hotline.Application.Snapshot;
- using Hotline.Caching.Interfaces;
- using Hotline.Configurations;
- using Hotline.Repository.SqlSugar.Extensions;
- using Hotline.Settings;
- using Hotline.Share.Dtos;
- using Hotline.Share.Dtos.Snapshot;
- using Hotline.Share.Tools;
- using Hotline.Snapshot;
- using Hotline.Snapshot.Interfaces;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.Options;
- namespace Hotline.Api.Controllers.Snapshot;
- /// <summary>
- /// 随手拍行业管理接口
- /// </summary>
- public class IndustryController : BaseController
- {
- private readonly IIndustryRepository _industryRepository;
- private readonly ISystemDicDataCacheManager _systemDicDataCacheManager;
- private readonly IIndustryApplication _industryApplication;
- private readonly ISystemAreaDomainService _systemAreaDomainService;
- private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
- public IndustryController(IIndustryRepository industryRepository, IIndustryApplication industryApplication, ISystemDicDataCacheManager systemDicDataCacheManager, ISystemAreaDomainService systemAreaDomainService, IOptionsSnapshot<AppConfiguration> appOptions)
- {
- _industryRepository = industryRepository;
- _industryApplication = industryApplication;
- _systemDicDataCacheManager = systemDicDataCacheManager;
- _systemAreaDomainService = systemAreaDomainService;
- _appOptions = appOptions;
- }
- /// <summary>
- /// 添加行业页面基础数据
- /// </summary>
- /// <returns></returns>
- [HttpGet("basedata")]
- public Dictionary<string, object> GetBaseData()
- {
- return new Dictionary<string, object>
- {
- { "department", _systemDicDataCacheManager.SnapshotDepartment },
- { "acceptType", _systemDicDataCacheManager.AcceptType},
- { "bulletinType", _systemDicDataCacheManager.SnapshotBulletinType}
- };
- }
- /// <summary>
- /// 新增行业
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public async Task<string> AddIndustry([FromBody] AddIndustryDto dto)
- => await _industryApplication.AddIndustryAsync(dto, HttpContext.RequestAborted);
- /// <summary>
- /// 行业详情
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet("{id}")]
- public async Task<IndustryDetailOutDto> GetIndustryDetailAsync(string id)
- => await _industryApplication.GetIndustryDetailAsync(id);
- /// <summary>
- /// 获取行业集合
- /// </summary>
- /// <returns></returns>
- [HttpGet("industry")]
- public async Task<PagedDto<IndustryItemsOutDto>> GetIndustryAsync([FromQuery] IndustryListInDto dto)
- => (await _industryApplication.GetIndustres(dto).ToPagedListAsync(dto, HttpContext.RequestAborted)).ToPaged();
- /// <summary>
- /// 修改行业
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPut]
- public async Task UpdateIndustry([FromBody] UpdateIndustryInDto dto)
- => await _industryApplication.UpdateIndustryAsync(dto, HttpContext.RequestAborted);
- #region 行业线索
- /// <summary>
- /// 行业线索集合
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpGet("case")]
- public async Task<PagedDto<IndustryCaseItemOutDto>> GetIndustryCaseItemAsync([FromQuery] IndustryCaseItemInDto dto)
- => (await _industryApplication.GetIndustryCaseItems(dto).ToPagedListAsync(dto, HttpContext.RequestAborted)).ToPaged();
- /// <summary>
- /// 添加行业线索
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost("case")]
- public async Task AddIndustryCaseAsync([FromBody] AddIndustryCaseDto dto)
- => await _industryApplication.AddIndustryCaseAsync(dto);
- /// <summary>
- /// 更新行业线索
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPut("case")]
- public async Task UpdateIndustryCaseAsync([FromBody]UpdateIndustryCaseDto dto)
- => await _industryApplication.UpdateIndustryCaseAsync(dto);
- /// <summary>
- /// 获取行业线索详情
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet("case/{id}")]
- public async Task<IndustryCase> GetIndustryCaseDetailAsync(string id)
- => await _industryApplication.GetIndustryCaseAsync(id);
- /// <summary>
- /// 页面基础数据
- /// </summary>
- /// <returns></returns>
- [HttpGet("case/database")]
- public async Task<Dictionary<string, object>> GetIndustryCaseDataBaseAsync()
- {
- var items = await _industryRepository.Queryable()
- .Select(m => new { m.Id, m.Name })
- .ToListAsync();
- return new Dictionary<string, object>
- {
- { "industry", items }
- };
- }
- #endregion
- #region 行业短信模板
- /// <summary>
- /// 行业短信模板集合
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpGet("sms_template")]
- public async Task<PagedDto<SnapshotSMSTemplateItemsOutDto>> GetSmsTemplateItemsAsync([FromQuery]SnapshotSMSTemplateItemsInDto dto)
- => (await _industryApplication.GetSMSTemplates(dto).ToPagedListAsync(dto, HttpContext.RequestAborted)).ToPaged();
- /// <summary>
- /// 添加行业短信模板
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost("sms_template")]
- public async Task AddSmsTemplateAsync([FromBody] AddSnapshotSMSTemplateInDto dto)
- => await _industryApplication.AddSMSTemplateAsync(dto);
- /// <summary>
- /// 修改行业短信模板
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPut("sms_template")]
- public async Task UpdateSmsTemplateAsync([FromBody] UpdateSnapshotSMSTemplateInDto dto)
- => await _industryApplication.UpdateSMSTemplateAsync(dto);
- /// <summary>
- /// 短信详情
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet("sms_template/{id}")]
- public async Task<SnapshotSMSTemplateItemsOutDto> GetSMSTemplateDetailAsync(string id)
- => await _industryApplication.GetSMSTemplateDetailAsync(id);
- #endregion
- #region 区域从业人员
- /// <summary>
- /// 区域从业人员集合
- /// </summary>
- /// <returns></returns>
- [HttpGet("practitioner")]
- public async Task<PagedDto<PractitionerItemsOutDto>> GetPractitionerItemsAsync([FromQuery] PractitionerItemsInDto dto)
- => (await _industryApplication.GetPractitionerItemsAsync(dto).ToPagedListAsync(dto, HttpContext.RequestAborted)).ToPaged();
- /// <summary>
- /// 添加区域从业人员
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost("practitioner")]
- public async Task<string> AddPractitionerAsync([FromBody]AddBatchPractitionerInDto dto)
- => await _industryApplication.AddPractitionerAsync(dto);
- /// <summary>
- /// 删除区域从业人员
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpDelete("practitioner")]
- public async Task DeletePractitionerAsync([FromBody]IList<string> ids)
- => await _industryApplication.DeletePractitionerAsync(ids);
- /// <summary>
- /// 从业人员详情
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet("practitioner/{id}")]
- public async Task<PractitionerItemsOutDto> GetPractitionerAsync(string id)
- => await _industryApplication.GetPractitionerAsync(id);
- /// <summary>
- /// 添加从业人员基础数据
- /// </summary>
- /// <returns></returns>
- [HttpGet("practitioner/basedata")]
- public async Task<Dictionary<string, object>> GetPractitionerDataBaseAsync()
- {
- var parentId = "";
- if (_appOptions.Value.IsZiGong) parentId = _appOptions.Value.ZiGong.AreaCode;
- return new Dictionary<string, object>
- {
- { "area", await _systemAreaDomainService.GetAreaTree(parentId: parentId)}
- };
- }
- #endregion
- }
|