123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317 |
- 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.Settings;
- using Hotline.Share.Dtos.Snapshot;
- using Hotline.Share.Tools;
- using Hotline.Snapshot;
- using Hotline.Snapshot.Interfaces;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.Options;
- using SqlSugar;
- 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;
- private readonly ISystemOrganizeRepository _systemOrganizeRepository;
- public IndustryController(IIndustryRepository industryRepository, IIndustryApplication industryApplication, ISystemDicDataCacheManager systemDicDataCacheManager, ISystemAreaDomainService systemAreaDomainService, IOptionsSnapshot<AppConfiguration> appOptions, ISystemOrganizeRepository systemOrganizeRepository)
- {
- _industryRepository = industryRepository;
- _industryApplication = industryApplication;
- _systemDicDataCacheManager = systemDicDataCacheManager;
- _systemAreaDomainService = systemAreaDomainService;
- _appOptions = appOptions;
- _systemOrganizeRepository = systemOrganizeRepository;
- }
- /// <summary>
- /// 添加行业页面基础数据
- /// </summary>
- /// <returns></returns>
- [HttpGet("basedata")]
- public async Task<Dictionary<string, object>> GetBaseData()
- {
- return new Dictionary<string, object>
- {
- { "department", await _systemOrganizeRepository.GetOrgEnabled() },
- { "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>> GetIndustres([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>> GetIndustryCaseItems([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>> GetSMSTemplates([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);
- /// <summary>
- /// 删除短信模板
- /// </summary>
- /// <param name="ids"></param>
- /// <returns></returns>
- [HttpDelete("sms_template")]
- public async Task DeleteSmsTemplateAsync([FromBody] IList<string> ids)
- => await _industryApplication.DeleteSMSTemplateAsync(ids);
- #endregion
- #region 区域从业人员
- /// <summary>
- /// 区域从业人员集合
- /// </summary>
- /// <returns></returns>
- [HttpGet("practitioner")]
- public async Task<PagedDto<PractitionerItemsOutDto>> GetPractitionerItems([FromQuery] PractitionerItemsInDto dto)
- => (await _industryApplication.GetPractitionerItems(dto).ToPagedListAsync(dto, HttpContext.RequestAborted)).ToPaged();
- /// <summary>
- /// 添加区域从业人员
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost("practitioner")]
- public async Task<string> AddPractitionerAsync([FromBody] AddPractitionerInDto dto)
- => await _industryApplication.AddPractitionerAsync(dto);
- /// <summary>
- /// 删除区域从业人员
- /// </summary>
- /// <param name="ids"></param>
- /// <returns></returns>
- [HttpDelete("practitioner")]
- public async Task DeletePractitionerAsync([FromBody] IList<string> ids)
- => await _industryApplication.DeletePractitionerAsync(ids);
- /// <summary>
- /// 修改区域从业人员
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPut("practitioner")]
- public async Task UpdatePractitionerAsync(UpdatePractitionerInDto dto)
- => await _industryApplication.UpdatePractitionerAsync(dto);
- /// <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
- #region 志愿者
- /// <summary>
- /// 志愿者集合
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpGet("volunteer")]
- public async Task<PagedDto<VolunteerItemsOutDto>> GetVolunteerItems([FromQuery] VolunteerItemsInDto dto)
- => (await _industryApplication.GetVolunteerItems(dto).ToPagedListAsync(dto, HttpContext.RequestAborted)).ToPaged();
- /// <summary>
- /// 添加志愿者
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost("volunteer")]
- public async Task<string> AddVolunteerAsync([FromBody] AddVolunteerInDto dto)
- => await _industryApplication.AddVolunteerAsync(dto);
- /// <summary>
- /// 批量删除志愿者
- /// </summary>
- /// <param name="ids"></param>
- /// <returns></returns>
- [HttpDelete("volunteer")]
- public async Task DeleteVolunteerAsync([FromBody] IList<string> ids)
- => await _industryApplication.DeleteVolunteerAsync(ids);
- /// <summary>
- /// 志愿者详情
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet("volunteer/{id}")]
- public async Task<Volunteer> GetVolunteerAsync(string id)
- => await _industryApplication.GetVolunteerAsync(id);
- /// <summary>
- /// 修改志愿者
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPut("volunteer")]
- public async Task UpdateVolunteerAsync([FromBody] UpdateVolunteerInDto dto)
- => await _industryApplication.UpdateVolunteerAsync(dto);
- /// <summary>
- /// 志愿者上报集合
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpGet("volunteer/report")]
- public async Task<PagedDto<VolunteerReportItemsOutDto>> GetVolunteerReportItems([FromQuery] VolunteerReportItemsInDto dto)
- => (await _industryApplication.GetVolunteerReportItems(dto).ToPagedListAsync(dto)).ToPaged();
- #endregion
- #region 修改行业记录
- /// <summary>
- /// 行业修改记录
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpGet("order/industry/log")]
- public async Task<PagedDto<IndustryLogItemsOutDto>> GetIndustryLogItems([FromQuery] IndustryLogItemsInDto dto)
- => (await _industryApplication.GetIndustryLogItems(dto).ToPagedListAsync(dto)).ToPaged();
- #endregion
- }
|