|
@@ -1,11 +1,17 @@
|
|
|
-using Hotline.Repository.SqlSugar.Extensions;
|
|
|
+using Hotline.Caches;
|
|
|
+using Hotline.Repository.SqlSugar.Extensions;
|
|
|
+using Hotline.Settings;
|
|
|
using Hotline.Settings.Hotspots;
|
|
|
using Hotline.Settings.TimeLimits;
|
|
|
using Hotline.Share.Dtos;
|
|
|
-using Hotline.Share.Dtos.Order;
|
|
|
+using Hotline.Share.Dtos.Settings;
|
|
|
+using Hotline.Share.Enums.Order;
|
|
|
+using Hotline.Share.Enums.Settings;
|
|
|
using MapsterMapper;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
+using StackExchange.Redis;
|
|
|
using XF.Domain.Exceptions;
|
|
|
+using XF.Utility.EnumExtensions;
|
|
|
|
|
|
namespace Hotline.Api.Controllers
|
|
|
{
|
|
@@ -18,13 +24,15 @@ namespace Hotline.Api.Controllers
|
|
|
private readonly IMapper _mapper;
|
|
|
private readonly ITimeLimitDomainService _timeLimitDomainService;
|
|
|
private readonly ITimeLimitRepository _timeLimitRepository;
|
|
|
+ private readonly ISysDicDataCacheManager _sysDicDataCacheManager;
|
|
|
|
|
|
- public HotspotController(IHotspotTypeRepository hotspotTypeRepository,IMapper mapper, ITimeLimitDomainService timeLimitDomainService, ITimeLimitRepository timeLimitRepository)
|
|
|
+ public HotspotController(IHotspotTypeRepository hotspotTypeRepository,IMapper mapper, ITimeLimitDomainService timeLimitDomainService, ITimeLimitRepository timeLimitRepository,ISysDicDataCacheManager sysDicDataCacheManager)
|
|
|
{
|
|
|
_hotspotTypeRepository = hotspotTypeRepository;
|
|
|
_mapper = mapper;
|
|
|
_timeLimitDomainService = timeLimitDomainService;
|
|
|
_timeLimitRepository = timeLimitRepository;
|
|
|
+ _sysDicDataCacheManager = sysDicDataCacheManager;
|
|
|
}
|
|
|
|
|
|
#region 热点
|
|
@@ -65,6 +73,26 @@ namespace Hotline.Api.Controllers
|
|
|
|
|
|
|
|
|
#region 时限管理
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 获取时限配置页面基础数据
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("timelimit-basedata")]
|
|
|
+ public async Task<object> GetTimeLimitBaseData()
|
|
|
+ {
|
|
|
+ return new {
|
|
|
+ BaseData = TimeLimitBaseData.GetBaseData(),
|
|
|
+ AcceptType = EnumExts.GetDescriptions<EAcceptType>(),
|
|
|
+ PushType = _sysDicDataCacheManager.GetSysDicDataCache(TimeLimitBaseDataConsts.PushType),
|
|
|
+ SourceChannel = EnumExts.GetDescriptions<EChannel>(),
|
|
|
+ IdentityType = EnumExts.GetDescriptions<EIdentityType>(),
|
|
|
+ OrderType = EnumExts.GetDescriptions<EOrderType>(),
|
|
|
+ CertType = _sysDicDataCacheManager.GetSysDicDataCache(TimeLimitBaseDataConsts.CertType),
|
|
|
+ EmergencyLevel = EnumExts.GetDescriptions<EEmergencyLevel>()
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 新增时限管理
|
|
|
/// </summary>
|
|
@@ -74,7 +102,7 @@ namespace Hotline.Api.Controllers
|
|
|
public async Task<string> AddTimeLimit([FromBody]AddTimeLimitDto dto)
|
|
|
{
|
|
|
var model = _mapper.Map<TimeLimit>(dto);
|
|
|
- model.TimeLimitState = Share.Enums.Order.ETimeLimitState.Draft;
|
|
|
+ model.TimeLimitState = ETimeLimitState.Draft;
|
|
|
return await _timeLimitDomainService.AddAsync(model, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
@@ -131,7 +159,7 @@ namespace Hotline.Api.Controllers
|
|
|
{
|
|
|
throw UserFriendlyException.SameMessage("无效数据");
|
|
|
}
|
|
|
- if (model.TimeLimitState != Share.Enums.Order.ETimeLimitState.Draft)
|
|
|
+ if (model.TimeLimitState != ETimeLimitState.Draft)
|
|
|
{
|
|
|
throw UserFriendlyException.SameMessage("无法删除,请刷新页面");
|
|
|
}
|
|
@@ -151,13 +179,13 @@ namespace Hotline.Api.Controllers
|
|
|
{
|
|
|
throw UserFriendlyException.SameMessage("无效数据");
|
|
|
}
|
|
|
- if (model.TimeLimitState == Share.Enums.Order.ETimeLimitState.Enable)
|
|
|
+ if (model.TimeLimitState == 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;
|
|
|
+ var list = await _timeLimitRepository.QueryAsync(x => x.WorkflowCode == model.WorkflowCode && x.TimeLimitState == ETimeLimitState.Enable);
|
|
|
+ list.ForEach(x => x.TimeLimitState = ETimeLimitState.Disable);
|
|
|
+ model.TimeLimitState = ETimeLimitState.Enable;
|
|
|
list.Add(model);
|
|
|
await _timeLimitRepository.UpdateRangeAsync(list, HttpContext.RequestAborted);
|
|
|
}
|
|
@@ -175,15 +203,15 @@ namespace Hotline.Api.Controllers
|
|
|
{
|
|
|
throw UserFriendlyException.SameMessage("无效数据");
|
|
|
}
|
|
|
- if (model.TimeLimitState == Share.Enums.Order.ETimeLimitState.Draft)
|
|
|
+ if (model.TimeLimitState == ETimeLimitState.Draft)
|
|
|
{
|
|
|
throw UserFriendlyException.SameMessage("该配置未生效,无法禁用");
|
|
|
}
|
|
|
- if (model.TimeLimitState == Share.Enums.Order.ETimeLimitState.Disable)
|
|
|
+ if (model.TimeLimitState == ETimeLimitState.Disable)
|
|
|
{
|
|
|
throw UserFriendlyException.SameMessage("该配置已禁用");
|
|
|
}
|
|
|
- model.TimeLimitState = Share.Enums.Order.ETimeLimitState.Disable;
|
|
|
+ model.TimeLimitState = ETimeLimitState.Disable;
|
|
|
await _timeLimitRepository.UpdateAsync(model, HttpContext.RequestAborted);
|
|
|
}
|
|
|
#endregion
|