|
@@ -10,6 +10,7 @@ using Hotline.Application.Systems;
|
|
|
using Hotline.Application.Tools;
|
|
|
using Hotline.File;
|
|
|
using Hotline.FlowEngine.WorkflowModules;
|
|
|
+using Hotline.FlowEngine.Workflows;
|
|
|
using Hotline.KnowledgeBase;
|
|
|
using Hotline.KnowledgeBase.Notifies;
|
|
|
using Hotline.Permissions;
|
|
@@ -36,6 +37,7 @@ using Microsoft.AspNetCore.Mvc;
|
|
|
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
|
|
using Org.BouncyCastle.Utilities.IO;
|
|
|
using SqlSugar;
|
|
|
+using System.Text;
|
|
|
using System.Threading;
|
|
|
using XF.Domain.Authentications;
|
|
|
using XF.Domain.Exceptions;
|
|
@@ -328,9 +330,37 @@ namespace Hotline.Api.Controllers
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost("batch_audit")]
|
|
|
- public async Task KnowledgeBatchAuditAsync()
|
|
|
- {
|
|
|
- // TODO: qcy 批量审核
|
|
|
+ public async Task<string> KnowledgeBatchAuditAsync([FromBody] KnowledgeBatchAuditInDto dto)
|
|
|
+ {
|
|
|
+ var result = new StringBuilder();
|
|
|
+ var fail = 0;
|
|
|
+ var success = 0;
|
|
|
+ foreach (var knowledgeId in dto.KnowledgeIds)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var knowledge = await _knowledgeDomainService.KnowledgeInfo(knowledgeId, HttpContext.RequestAborted);
|
|
|
+ dto.NextWorkflowDto.WorkflowId = knowledge.WorkflowId;
|
|
|
+ var next = await _workflowApplication.GetNextStepsAsync(knowledge.WorkflowId, HttpContext.RequestAborted);
|
|
|
+ dto.NextWorkflowDto.StepId = next.StepId;
|
|
|
+ dto.NextWorkflowDto.NextStepCode = next.Steps.First().Key;
|
|
|
+ dto.NextWorkflowDto.NextStepName = next.Steps.First().Value;
|
|
|
+ if (dto.IsPass)
|
|
|
+ await _workflowApplication.NextAsync(dto.NextWorkflowDto, cancellationToken: HttpContext.RequestAborted);
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var reject = dto.NextWorkflowDto.Adapt<RejectDto>();
|
|
|
+ await _workflowApplication.RejectAsync(reject, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (UserFriendlyException e)
|
|
|
+ {
|
|
|
+ result.Append(e.Message);
|
|
|
+ fail++;
|
|
|
+ }
|
|
|
+ success++;
|
|
|
+ }
|
|
|
+ return $"总共: {dto.KnowledgeIds.Length}, 成功: {success}, 失败: {fail}, 失败原因: {result.ToString()}";
|
|
|
}
|
|
|
|
|
|
/// <summary>
|