From cac0a4cd169857c7eaad80b5fff1c989d0981bd0 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期四, 29 八月 2024 14:12:07 +0800
Subject: [PATCH] update 优化 RegexUtils#extractFromString 方法未匹配返回null不返回默认值问题
---
ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/flowable/cmd/AttachmentCmd.java | 28 +++++++++++++---------------
1 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/flowable/cmd/AttachmentCmd.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/flowable/cmd/AttachmentCmd.java
index f011252..20a0a5f 100644
--- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/flowable/cmd/AttachmentCmd.java
+++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/flowable/cmd/AttachmentCmd.java
@@ -1,20 +1,16 @@
package org.dromara.workflow.flowable.cmd;
import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.util.StrUtil;
-import org.dromara.common.core.utils.SpringUtils;
-import org.dromara.common.core.utils.StreamUtils;
+import org.dromara.common.core.domain.dto.OssDTO;
+import org.dromara.common.core.service.OssService;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.satoken.utils.LoginHelper;
-import org.dromara.system.domain.vo.SysOssVo;
-import org.dromara.system.service.ISysOssService;
import org.flowable.common.engine.impl.interceptor.Command;
import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.engine.impl.persistence.entity.AttachmentEntity;
import org.flowable.engine.impl.persistence.entity.AttachmentEntityManager;
import org.flowable.engine.impl.util.CommandContextUtil;
-import java.util.Arrays;
import java.util.Date;
import java.util.List;
@@ -31,30 +27,32 @@
private final String processInstanceId;
- public AttachmentCmd(String fileId, String taskId, String processInstanceId) {
+ private final OssService ossService;
+
+ public AttachmentCmd(String fileId, String taskId, String processInstanceId, OssService ossService) {
this.fileId = fileId;
this.taskId = taskId;
this.processInstanceId = processInstanceId;
+ this.ossService = ossService;
}
@Override
public Boolean execute(CommandContext commandContext) {
try {
if (StringUtils.isNotBlank(fileId)) {
- List<Long> fileIds = StreamUtils.toList(Arrays.asList(fileId.split(StrUtil.COMMA)), Long::valueOf);
- List<SysOssVo> sysOssVos = SpringUtils.getBean(ISysOssService.class).listByIds(fileIds);
- if (CollUtil.isNotEmpty(sysOssVos)) {
- for (SysOssVo sysOssVo : sysOssVos) {
+ List<OssDTO> ossList = ossService.selectByIds(fileId);
+ if (CollUtil.isNotEmpty(ossList)) {
+ for (OssDTO oss : ossList) {
AttachmentEntityManager attachmentEntityManager = CommandContextUtil.getAttachmentEntityManager();
AttachmentEntity attachmentEntity = attachmentEntityManager.create();
attachmentEntity.setRevision(1);
attachmentEntity.setUserId(LoginHelper.getUserId().toString());
- attachmentEntity.setName(sysOssVo.getOriginalName());
- attachmentEntity.setDescription(sysOssVo.getOriginalName());
- attachmentEntity.setType(sysOssVo.getFileSuffix());
+ attachmentEntity.setName(oss.getOriginalName());
+ attachmentEntity.setDescription(oss.getOriginalName());
+ attachmentEntity.setType(oss.getFileSuffix());
attachmentEntity.setTaskId(taskId);
attachmentEntity.setProcessInstanceId(processInstanceId);
- attachmentEntity.setContentId(sysOssVo.getOssId().toString());
+ attachmentEntity.setContentId(oss.getOssId().toString());
attachmentEntity.setTime(new Date());
attachmentEntityManager.insert(attachmentEntity);
}
--
Gitblit v1.9.3