拦截 处理签名系统文档 添加更新项目
parent
8838871c0d
commit
27f40962f7
|
@ -52,7 +52,7 @@ namespace IRaCIS.Core.API.Controllers.Special
|
||||||
[HttpPost, Route("trial/addOrUpdateTrial")]
|
[HttpPost, Route("trial/addOrUpdateTrial")]
|
||||||
[Authorize(Policy = IRaCISPolicy.PM_APM)]
|
[Authorize(Policy = IRaCISPolicy.PM_APM)]
|
||||||
|
|
||||||
[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
|
[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AddOrUpdateTrial", "BeforeOngoingCantOpt", "AfterStopCannNotOpt" })]
|
||||||
public async Task<IResponseOutput<Trial>> AddOrUpdateTrial(TrialCommand param)
|
public async Task<IResponseOutput<Trial>> AddOrUpdateTrial(TrialCommand param)
|
||||||
{
|
{
|
||||||
var userId = Guid.Parse(User.FindFirst("id").Value);
|
var userId = Guid.Parse(User.FindFirst("id").Value);
|
||||||
|
|
|
@ -428,7 +428,7 @@ namespace IRaCIS.Core.API.Controllers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost, Route("Inspection/TrialDocument/userConfirm")]
|
[HttpPost, Route("Inspection/TrialDocument/userConfirm")]
|
||||||
[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
|
[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "SignSystemDocNoTrialId", "AfterStopCannNotOpt" })]
|
||||||
[UnitOfWork]
|
[UnitOfWork]
|
||||||
public async Task<IResponseOutput> UserConfirm(DataInspectionDto<UserConfirmCommand> opt)
|
public async Task<IResponseOutput> UserConfirm(DataInspectionDto<UserConfirmCommand> opt)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,30 +16,41 @@ namespace IRaCIS.Core.Application.Filter
|
||||||
private readonly IEasyCachingProvider _provider;
|
private readonly IEasyCachingProvider _provider;
|
||||||
private readonly IUserInfo _userInfo;
|
private readonly IUserInfo _userInfo;
|
||||||
|
|
||||||
private readonly string _trialOpt;
|
|
||||||
|
|
||||||
//private readonly List<string> _trialOptList;
|
private readonly List<string> _trialOptList=new List<string>();
|
||||||
|
|
||||||
|
|
||||||
public TrialResourceFilter(IEasyCachingProvider provider, IUserInfo userInfo, string trialOpt)
|
public TrialResourceFilter(IEasyCachingProvider provider, IUserInfo userInfo, string trialOpt = null, string trialOpt2 = null, string trialOpt3 = null)
|
||||||
{
|
{
|
||||||
_provider = provider;
|
_provider = provider;
|
||||||
_userInfo = userInfo;
|
_userInfo = userInfo;
|
||||||
_trialOpt = trialOpt;
|
//_trialOpt = trialOpt;
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(trialOpt)) _trialOptList.Add(trialOpt);
|
||||||
|
if (!string.IsNullOrWhiteSpace(trialOpt2)) _trialOptList.Add(trialOpt2);
|
||||||
|
if (!string.IsNullOrWhiteSpace(trialOpt3)) _trialOptList.Add(trialOpt3);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//public TrialResourceFilter(IEasyCachingProvider provider, IUserInfo userInfo, List<string> trialOptList=new list)
|
|
||||||
|
//public TrialResourceFilter(IEasyCachingProvider provider, IUserInfo userInfo)
|
||||||
//{
|
//{
|
||||||
// _provider = provider;
|
// _provider = provider;
|
||||||
// _userInfo = userInfo;
|
// _userInfo = userInfo;
|
||||||
// _trialOptList = trialOptList;
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//优先选择异步的方法
|
//优先选择异步的方法
|
||||||
public async Task OnResourceExecutionAsync(ResourceExecutingContext context, ResourceExecutionDelegate next)
|
public async Task OnResourceExecutionAsync(ResourceExecutingContext context, ResourceExecutionDelegate next)
|
||||||
{
|
{
|
||||||
|
// var typeFilter = context.ActionDescriptor.EndpointMetadata.Where(t => t.GetType() == typeof(TypeFilterAttribute)).Select(t => (TypeFilterAttribute)t).ToList().FirstOrDefault();
|
||||||
|
//var _trialOptList= typeFilter.Arguments.Select(t => t.ToString()).ToList();
|
||||||
|
|
||||||
#region 处理新的用户类型,不能操作项目相关接口
|
#region 处理新的用户类型,不能操作项目相关接口
|
||||||
|
|
||||||
// 后期列举出具体的类型,其他任何用户类型,都不允许操作
|
// 后期列举出具体的类型,其他任何用户类型,都不允许操作
|
||||||
|
@ -118,7 +129,7 @@ namespace IRaCIS.Core.Application.Filter
|
||||||
}
|
}
|
||||||
|
|
||||||
//使用字符串取 如果是swagger 可能有时取的不对 因为空格的原因
|
//使用字符串取 如果是swagger 可能有时取的不对 因为空格的原因
|
||||||
//trialIdStr = contentFromBody.Substring(trialIdIndex + "TrialId".Length + 4, 36);
|
//trialIdStr = contentFromBody.Substring(trialIdIndex + "TrialId".Length + 4, 3
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -145,7 +156,7 @@ namespace IRaCIS.Core.Application.Filter
|
||||||
var trialStatusStr = cacheResultDic[trialIdStr];
|
var trialStatusStr = cacheResultDic[trialIdStr];
|
||||||
|
|
||||||
// 这里是统一拦截 项目有关的操作允许情况(特殊的地方,比如项目配置(有的在多种状态(初始化,ongoing)都可以操作,有的仅仅在Initializing)还有 项目添加和更新,不走这里,特殊处理,不然在这里显得很乱,判断是哪个接口)
|
// 这里是统一拦截 项目有关的操作允许情况(特殊的地方,比如项目配置(有的在多种状态(初始化,ongoing)都可以操作,有的仅仅在Initializing)还有 项目添加和更新,不走这里,特殊处理,不然在这里显得很乱,判断是哪个接口)
|
||||||
if (trialStatusStr.Value == StaticData.TrialState.TrialOngoing || _trialOpt == TrialOpt.BeforeOngoingCantOpt)
|
if (trialStatusStr.Value == StaticData.TrialState.TrialOngoing || _trialOptList.Any(t=>t== TrialOpt.BeforeOngoingCantOpt) )
|
||||||
{
|
{
|
||||||
|
|
||||||
await next.Invoke();
|
await next.Invoke();
|
||||||
|
@ -159,7 +170,10 @@ namespace IRaCIS.Core.Application.Filter
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else if (_trialOptList.Any(t => t == TrialOpt.AddOrUpdateTrial ||t ==TrialOpt.SignSystemDocNoTrialId))
|
||||||
|
{
|
||||||
|
await next.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -876,7 +876,7 @@ namespace IRaCIS.Core.Application
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPut("{trialId:guid}/{isAbandon:bool}")]
|
[HttpPut("{trialId:guid}/{isAbandon:bool}")]
|
||||||
[Authorize(Policy = IRaCISPolicy.PM)]
|
[Authorize(Policy = IRaCISPolicy.PM)]
|
||||||
[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
|
[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt", "AfterStopCannNotOpt" })]
|
||||||
public async Task<IResponseOutput> AbandonTrial(Guid trialId, /*Guid? signId,*/ bool isAbandon)
|
public async Task<IResponseOutput> AbandonTrial(Guid trialId, /*Guid? signId,*/ bool isAbandon)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -911,7 +911,7 @@ namespace IRaCIS.Core.Application
|
||||||
/// <param name="trialConfig"></param>
|
/// <param name="trialConfig"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPut]
|
[HttpPut]
|
||||||
[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "BeforeOngoingCantOpt" })]
|
[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "BeforeOngoingCantOpt", "AfterStopCannNotOpt" })]
|
||||||
//[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
|
//[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
|
||||||
public async Task<IResponseOutput> ConfigTrialTaskInfo(TrialTaskConfig trialConfig)
|
public async Task<IResponseOutput> ConfigTrialTaskInfo(TrialTaskConfig trialConfig)
|
||||||
{
|
{
|
||||||
|
@ -929,7 +929,7 @@ namespace IRaCIS.Core.Application
|
||||||
/// <param name="trialConfig"></param>
|
/// <param name="trialConfig"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPut]
|
[HttpPut]
|
||||||
[TypeFilter(typeof(TrialResourceFilter),Arguments = new object[] { "BeforeOngoingCantOpt" })]
|
[TypeFilter(typeof(TrialResourceFilter),Arguments = new object[] { "BeforeOngoingCantOpt", "AfterStopCannNotOpt" })]
|
||||||
//[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
|
//[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
|
||||||
public async Task<IResponseOutput> ConfigTrialReadingTaskViewRule(TrialReadingTaskViewConfig trialConfig)
|
public async Task<IResponseOutput> ConfigTrialReadingTaskViewRule(TrialReadingTaskViewConfig trialConfig)
|
||||||
{
|
{
|
||||||
|
|
|
@ -104,7 +104,7 @@ namespace IRaCIS.Application.Services
|
||||||
[UnitOfWork]
|
[UnitOfWork]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Policy = IRaCISPolicy.PM_APM)]
|
[Authorize(Policy = IRaCISPolicy.PM_APM)]
|
||||||
[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "BeforeOngoingCantOpt" })]
|
[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "BeforeOngoingCantOpt", "AfterStopCannNotOpt" })]
|
||||||
//[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
|
//[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
|
||||||
public async Task<IResponseOutput> AddOrUpdateVisitStage(VisitPlanCommand visitPlan)
|
public async Task<IResponseOutput> AddOrUpdateVisitStage(VisitPlanCommand visitPlan)
|
||||||
{
|
{
|
||||||
|
@ -207,7 +207,7 @@ namespace IRaCIS.Application.Services
|
||||||
[UnitOfWork]
|
[UnitOfWork]
|
||||||
[HttpPost("{trialId:guid}")]
|
[HttpPost("{trialId:guid}")]
|
||||||
[Authorize(Policy = IRaCISPolicy.PM_APM)]
|
[Authorize(Policy = IRaCISPolicy.PM_APM)]
|
||||||
[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "BeforeOngoingCantOpt" })]
|
[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "BeforeOngoingCantOpt", "AfterStopCannNotOpt" })]
|
||||||
//[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
|
//[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
|
||||||
public async Task<IResponseOutput> ConfirmTrialVisitPlan(Guid trialId)
|
public async Task<IResponseOutput> ConfirmTrialVisitPlan(Guid trialId)
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,6 +58,11 @@ public static class StaticData
|
||||||
|
|
||||||
//ongoing 前能操作 但是Stop后 也不能操作
|
//ongoing 前能操作 但是Stop后 也不能操作
|
||||||
public static readonly string BeforeOngoingCantOpt = "BeforeOngoingCantOpt";
|
public static readonly string BeforeOngoingCantOpt = "BeforeOngoingCantOpt";
|
||||||
|
|
||||||
|
public static readonly string AddOrUpdateTrial = "AddOrUpdateTrial";
|
||||||
|
|
||||||
|
public static readonly string SignSystemDocNoTrialId = "SignSystemDocNoTrialId";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue