xf 6 сар өмнө
parent
commit
3badf38043

+ 4 - 0
src/Hotline.Application.Contracts/Validators/FlowEngine/NextWorkflowDtoValidator.cs

@@ -13,6 +13,10 @@ namespace Hotline.Application.Contracts.Validators.FlowEngine
         public NextWorkflowDtoValidator()
         {
             RuleFor(d => d.WorkflowId).NotEmpty();
+            RuleFor(d => d.Opinion)
+                .Cascade(CascadeMode.Stop)
+                .NotEmpty()
+                .MaximumLength(2000);
             //RuleFor(d=>d.ExpiredTime).NotEmpty();
             //RuleFor(d=>d.NextStepCode).NotEmpty();
         }

+ 5 - 0
src/Hotline.Application/FlowEngine/WorkflowApplication.cs

@@ -285,6 +285,11 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
     /// </summary>
     public async Task<Workflow> NextAsync(NextWorkflowDto dto, DateTime? expiredTime = null, CancellationToken cancellationToken = default)
     {
+        var validator = new NextWorkflowDtoValidator();
+        var validResult = await validator.ValidateAsync(dto, cancellationToken);
+        if (!validResult.IsValid)
+            throw new UserFriendlyException(
+                $"非法参数, {string.Join(',', validResult.Errors.Select(d => d.ErrorMessage))}");
         var workflow = await _workflowDomainService.GetWorkflowAsync(dto.WorkflowId, withDefine: true, withSteps: true,
             withTraces: true, withCountersigns: true, cancellationToken: cancellationToken);
 

+ 2 - 5
src/Hotline/FlowEngine/Workflows/WorkflowDomainService.cs

@@ -230,8 +230,7 @@ namespace Hotline.FlowEngine.Workflows
         /// <summary>
         /// 查询工作流包含当前用户结束会签权限(是否可结束)
         /// </summary>
-        public async Task<(Workflow Workflow, string? CountersignId, bool CanHandle, bool CanPrevious, WorkflowTrace?
-                Trace)>
+        public async Task<(Workflow Workflow, string? CountersignId, bool CanHandle, bool CanPrevious, WorkflowTrace? Trace)>
             GetWorkflowHandlePermissionAsync(
                 string workflowId, string userId, string orgId, string[] roleIds,
                 CancellationToken cancellationToken = default)
@@ -817,9 +816,7 @@ namespace Hotline.FlowEngine.Workflows
         /// 批量修改工单办理对象
         /// </summary>
         public async Task ChangeHandlerBatchAsync(
-            IReadOnlyList<(string userId, string username, string orgId, string orgName, string? roleId, string? roleName, ICollection<WorkflowStep>
-                steps
-                )> handlers,
+            IReadOnlyList<(string userId, string username, string orgId, string orgName, string? roleId, string? roleName, ICollection<WorkflowStep> steps)> handlers,
             CancellationToken cancellationToken)
         {
             foreach (var handler in handlers)