fix(缺陷管理): 富文本临时图片上传问题

--bug=1047792 --user=宋昌昌 【缺陷管理】编辑缺陷-点击更新按钮-报SQL异常 https://www.tapd.cn/55049933/s/1600345
This commit is contained in:
song-cc-rock 2024-10-29 14:57:44 +08:00 committed by Craftsman
parent 4d1538147a
commit 94ec9cf0ca
1 changed files with 11 additions and 6 deletions

View File

@ -622,9 +622,13 @@ public class BugAttachmentService {
// 添加文件与功能用例的关联关系 // 添加文件与功能用例的关联关系
Map<String, String> addFileMap = Maps.newHashMapWithExpectedSize(8); Map<String, String> addFileMap = Maps.newHashMapWithExpectedSize(8);
LogUtils.info("开始上传富文本里的附件"); LogUtils.info("开始上传富文本里的附件");
List<BugLocalAttachment> localAttachments = fileIds.stream().map(fileId -> { List<BugLocalAttachment> localAttachments = new ArrayList<>();
BugLocalAttachment localAttachment = new BugLocalAttachment(); for (String fileId : fileIds) {
String fileName = getTempFileNameByFileId(fileId); String fileName = getTempFileNameByFileId(fileId);
if (StringUtils.isEmpty(fileName)) {
continue;
}
BugLocalAttachment localAttachment = new BugLocalAttachment();
localAttachment.setId(IDGenerator.nextStr()); localAttachment.setId(IDGenerator.nextStr());
localAttachment.setBugId(bugId); localAttachment.setBugId(bugId);
localAttachment.setFileId(fileId); localAttachment.setFileId(fileId);
@ -643,10 +647,11 @@ public class BugAttachmentService {
localAttachment.setCreateUser(userId); localAttachment.setCreateUser(userId);
localAttachment.setCreateTime(System.currentTimeMillis()); localAttachment.setCreateTime(System.currentTimeMillis());
addFileMap.put(fileId, fileName); addFileMap.put(fileId, fileName);
return localAttachment; localAttachments.add(localAttachment);
}).toList(); }
List<BugLocalAttachment> normalAttachments = localAttachments.stream().filter(attachment -> StringUtils.isNotEmpty(attachment.getFileName())).toList(); if (!CollectionUtils.isEmpty(localAttachments)) {
bugLocalAttachmentMapper.batchInsert(normalAttachments); bugLocalAttachmentMapper.batchInsert(localAttachments);
}
// 上传文件到对象存储 // 上传文件到对象存储
LogUtils.info("upload to minio start"); LogUtils.info("upload to minio start");
String bugDir = DefaultRepositoryDir.getBugDir(projectId, bugId); String bugDir = DefaultRepositoryDir.getBugDir(projectId, bugId);