|
@@ -1,6 +1,13 @@
|
|
|
-using Hotline.Orders;
|
|
|
+using Hotline.CallCenter.Ivrs;
|
|
|
+using Hotline.Orders;
|
|
|
+using Hotline.Repository.SqlSugar.Extensions;
|
|
|
+using Hotline.Share.Dtos;
|
|
|
+using Hotline.Share.Dtos.Order;
|
|
|
+using MapsterMapper;
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
+using XF.Domain.Exceptions;
|
|
|
+using static Google.Rpc.Context.AttributeContext.Types;
|
|
|
|
|
|
namespace Hotline.Api.Controllers
|
|
|
{
|
|
@@ -10,12 +17,19 @@ namespace Hotline.Api.Controllers
|
|
|
public class HotspotController : BaseController
|
|
|
{
|
|
|
private readonly IHotspotTypeRepository _hotspotTypeRepository;
|
|
|
+ private readonly IMapper _mapper;
|
|
|
+ private readonly ITimeLimitDomainService _timeLimitDomainService;
|
|
|
+ private readonly ITimeLimitRepository _timeLimitRepository;
|
|
|
|
|
|
- public HotspotController(IHotspotTypeRepository hotspotTypeRepository)
|
|
|
+ public HotspotController(IHotspotTypeRepository hotspotTypeRepository,IMapper mapper, ITimeLimitDomainService timeLimitDomainService, ITimeLimitRepository timeLimitRepository)
|
|
|
{
|
|
|
_hotspotTypeRepository = hotspotTypeRepository;
|
|
|
+ _mapper = mapper;
|
|
|
+ _timeLimitDomainService = timeLimitDomainService;
|
|
|
+ _timeLimitRepository = timeLimitRepository;
|
|
|
}
|
|
|
|
|
|
+ #region 热点
|
|
|
/// <summary>
|
|
|
/// 查询子项
|
|
|
/// </summary>
|
|
@@ -48,5 +62,132 @@ namespace Hotline.Api.Controllers
|
|
|
hotspots.AddRange(targetList);
|
|
|
return hotspots.OrderBy(d=>d.HotSpotName).ToList();
|
|
|
}
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+
|
|
|
+ #region 时限管理
|
|
|
+ /// <summary>
|
|
|
+ /// 新增时限管理
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns>数据主键</returns>
|
|
|
+ [HttpPost("add-timelimit")]
|
|
|
+ public async Task<string> AddTimeLimit([FromBody]AddTimeLimitDto dto)
|
|
|
+ {
|
|
|
+ var model = _mapper.Map<TimeLimit>(dto);
|
|
|
+ model.TimeLimitState = Share.Enums.Order.ETimeLimitState.Draft;
|
|
|
+ return await _timeLimitDomainService.AddAsync(model, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 修改时限管理
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("update-timelimit")]
|
|
|
+ public async Task UpdateTimeLimit([FromBody]UpdateTimeLimitDto dto)
|
|
|
+ {
|
|
|
+ var model = _mapper.Map<TimeLimit>(dto);
|
|
|
+ await _timeLimitDomainService.UpdateAsync(model, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 获取对象
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="id"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("timelimit/{id}")]
|
|
|
+ public async Task<TimeLimit?> GetTimeLimit(string id)
|
|
|
+ {
|
|
|
+ return await _timeLimitRepository.GetAsync(id, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 获取时限管理列表
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("paged-timelimit")]
|
|
|
+ public async Task<PagedDto<TimeLimit>> QueryPagedTimeLimit([FromQuery] QueryPagedTimeLimitPagedDto dto)
|
|
|
+ {
|
|
|
+ var (total, items) = await _timeLimitRepository.Queryable()
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.Keyword), d => d.TimeLimitName.Contains(dto.Keyword!))
|
|
|
+ .OrderByDescending(d => d.CreationTime)
|
|
|
+ .ToPagedListAsync(dto.PageIndex,dto.PageSize, HttpContext.RequestAborted);
|
|
|
+ return new PagedDto<TimeLimit>(total, _mapper.Map<IReadOnlyList<TimeLimit>>(items));
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 删除时限(草稿)
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="id"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpDelete("deltimelimit")]
|
|
|
+ public async Task DelTimeLimit(string id)
|
|
|
+ {
|
|
|
+ var model = await _timeLimitRepository.GetAsync(id, HttpContext.RequestAborted);
|
|
|
+ if (model==null)
|
|
|
+ {
|
|
|
+ throw UserFriendlyException.SameMessage("无效数据");
|
|
|
+ }
|
|
|
+ if (model.TimeLimitState != Share.Enums.Order.ETimeLimitState.Draft)
|
|
|
+ {
|
|
|
+ throw UserFriendlyException.SameMessage("无法删除,请刷新页面");
|
|
|
+ }
|
|
|
+ await _timeLimitRepository.RemoveAsync(id,true,HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 启用时限
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="id"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("enable-timelimit/{id}")]
|
|
|
+ public async Task EnableTimeLimit(string id)
|
|
|
+ {
|
|
|
+ var model = await _timeLimitRepository.GetAsync(id, HttpContext.RequestAborted);
|
|
|
+ if (model==null)
|
|
|
+ {
|
|
|
+ throw UserFriendlyException.SameMessage("无效数据");
|
|
|
+ }
|
|
|
+ if (model.TimeLimitState == Share.Enums.Order.ETimeLimitState.Enable)
|
|
|
+ {
|
|
|
+ throw UserFriendlyException.SameMessage("该配置已生效");
|
|
|
+ }
|
|
|
+ var list = await _timeLimitRepository.QueryAsync(x => x.WorkflowCode == model.WorkflowCode && x.TimeLimitState == Share.Enums.Order.ETimeLimitState.Enable);
|
|
|
+ list.ForEach(x => x.TimeLimitState = Share.Enums.Order.ETimeLimitState.Disable);
|
|
|
+ model.TimeLimitState = Share.Enums.Order.ETimeLimitState.Enable;
|
|
|
+ list.Add(model);
|
|
|
+ await _timeLimitRepository.UpdateRangeAsync(list, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 禁用时限
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="id"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("disable-timelimit/{id}")]
|
|
|
+ public async Task DisableTimeLimit(string id)
|
|
|
+ {
|
|
|
+ var model = await _timeLimitRepository.GetAsync(id, HttpContext.RequestAborted);
|
|
|
+ if (model == null)
|
|
|
+ {
|
|
|
+ throw UserFriendlyException.SameMessage("无效数据");
|
|
|
+ }
|
|
|
+ if (model.TimeLimitState == Share.Enums.Order.ETimeLimitState.Draft)
|
|
|
+ {
|
|
|
+ throw UserFriendlyException.SameMessage("该配置未生效,无法禁用");
|
|
|
+ }
|
|
|
+ if (model.TimeLimitState == Share.Enums.Order.ETimeLimitState.Disable)
|
|
|
+ {
|
|
|
+ throw UserFriendlyException.SameMessage("该配置已禁用");
|
|
|
+ }
|
|
|
+ model.TimeLimitState = Share.Enums.Order.ETimeLimitState.Disable;
|
|
|
+ await _timeLimitRepository.UpdateAsync(model, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
}
|
|
|
}
|