fix(workflow): 修复工作流附件处理和请求参数绑定问题

- 将 ApiResult 中的 Attachments 类型从 List<IFormFile> 改为 List<string>
- 将控制器中 InitiateFlow 方法的参数绑定方式从 [FromForm] 改为 [FromBody]
- 移除多余的流程引擎初始化代码中的空行
- 修改附件保存逻辑,直接使用逗号分隔的字符串格式替代文件上传处理
- 在草稿保存功能中同步附件处理逻辑,确保数据格式一致
main
陈伟 2026-02-05 13:51:07 +08:00
parent 3e30965bc4
commit 84f06b463f
3 changed files with 6 additions and 6 deletions

View File

@ -74,9 +74,7 @@ public class WorkflowEngineApp : SqlSugarBaseApp<SysCategoryType, SugarDbContext
throw new Exception("流程编码和业务编号不能为空");
if (userId <= 0 || string.IsNullOrEmpty(userName))
throw new Exception("发起人ID和姓名不能为空");
var instanceId = 0L;
try
{
// 开启事务基于UnitWork保障数据一致性
@ -126,7 +124,8 @@ public class WorkflowEngineApp : SqlSugarBaseApp<SysCategoryType, SugarDbContext
_sqlSugar.Insertable(startWorkitem).ExecuteCommand();
// 步骤5保存流程变量标题、附件路径等
var attachmentPaths = SaveAttachments(requestDto.Attachments);
//var attachmentPaths = SaveAttachments(requestDto.Attachments);
var attachmentPaths = string.Join(",", requestDto.Attachments);
var flowVariables = new List<ZyFlowVariable>
{
new() { InstanceId = instanceId, VarKey = "Title", VarValue = requestDto.Title },
@ -991,6 +990,7 @@ public class WorkflowEngineApp : SqlSugarBaseApp<SysCategoryType, SugarDbContext
/// <exception cref="NotImplementedException"></exception>
public object SaveDraft(InitiateFlowRequestDto requestDto)
{
var attachmentPaths = string.Join(",", requestDto.Attachments);
var user = _auth.GetCurrentUser().User;
var illegalConstructionAssessment = new IllegalConstructionAssessment
{
@ -998,7 +998,7 @@ public class WorkflowEngineApp : SqlSugarBaseApp<SysCategoryType, SugarDbContext
Id = requestDto.BusinessNo,
Title = requestDto.Title,
BusinessNumber = requestDto.BusinessNo,
Attachments = requestDto.Attachments != null ? SaveAttachments(requestDto.Attachments) : string.Empty,
Attachments = requestDto.Attachments != null ? attachmentPaths : string.Empty,
AcceptanceTime = DateTime.Now,
Status = "Draft",
CreateTime = DateTime.Now,

View File

@ -33,7 +33,7 @@ public class InitiateFlowRequestDto
/// <summary>
/// 上传附件列表(业务相关证明材料、表单等)
/// </summary>
public List<IFormFile> Attachments { get; set; } = new List<IFormFile>();
public List<string> Attachments { get; set; } = new();
}
/// <summary>

View File

@ -34,7 +34,7 @@ public class WorkflowController : ControllerBase
/// <param name="requestDto">发起流程请求参数</param>
/// <returns>流程实例ID</returns>
[HttpPost]
public ActionResult<ApiResponseDto<long>> InitiateFlow([FromForm] InitiateFlowRequestDto requestDto)
public ActionResult<ApiResponseDto<long>> InitiateFlow([FromBody] InitiateFlowRequestDto requestDto)
{
try
{