From 4fe35c8578d93e0e99fc7c0b30961034abf99ded Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Fri, 20 Sep 2024 16:38:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B):=20?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E6=A8=A1=E6=9D=BF=E5=9B=BE=E7=89=87=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1046616 --user=王旭 【测试计划】项目未集成三方-功能用例-新建缺陷-自定义模版-创建报SQL异常 https://www.tapd.cn/55049933/s/1582334 --- .../functional/service/FunctionalCaseService.java | 13 ++++++++++++- .../controller/FunctionalCaseControllerTests.java | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java index c1e9f54f83..3f74c9914f 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java @@ -190,6 +190,7 @@ public class FunctionalCaseService { List uploadFileIds = functionalCaseAttachmentService.uploadFile(request.getProjectId(), caseId, files, true, userId); //上传富文本里的文件 + filterCaseDetailTmpFile(request); functionalCaseAttachmentService.uploadMinioFile(caseId, request.getProjectId(), request.getCaseDetailFileIds(), userId, CaseFileSourceType.CASE_DETAIL.toString()); //关联附件 @@ -211,6 +212,16 @@ public class FunctionalCaseService { return functionalCase; } + private void filterCaseDetailTmpFile(FunctionalCaseAddRequest request) { + // 非用例上传的图片文件不处理 + if (CollectionUtils.isNotEmpty(request.getCaseDetailFileIds())) { + request.getCaseDetailFileIds().removeIf(tmpFileId -> !request.getDescription().contains("/attachment/download/file/" + request.getProjectId() + "/" + tmpFileId)); + request.getCaseDetailFileIds().removeIf(tmpFileId -> !request.getTextDescription().contains("/attachment/download/file/" + request.getProjectId() + "/" + tmpFileId)); + request.getCaseDetailFileIds().removeIf(tmpFileId -> !request.getExpectedResult().contains("/attachment/download/file/" + request.getProjectId() + "/" + tmpFileId)); + request.getCaseDetailFileIds().removeIf(tmpFileId -> !request.getPrerequisite().contains("/attachment/download/file/" + request.getProjectId() + "/" + tmpFileId)); + } + } + private void copyAttachment(FunctionalCaseAddRequest request, String userId, List uploadFileIds, String caseId) { //获取用例已经上传的文件ID Map attachmentDTOMap = request.getAttachments().stream().collect(Collectors.toMap(FunctionalCaseAttachmentDTO::getId, t -> t)); @@ -1277,7 +1288,7 @@ public class FunctionalCaseService { } private void setCustomFieldValue(Object value, FunctionalCaseCustomField caseCustomField) { - if (value !=null && (StringUtils.equalsIgnoreCase(value.toString(), "[]") || value instanceof List)) { + if (value != null && (StringUtils.equalsIgnoreCase(value.toString(), "[]") || value instanceof List)) { //数组类型 caseCustomField.setValue(JSON.toJSONString(value)); } else { diff --git a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseControllerTests.java b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseControllerTests.java index 7b99f068e9..edd59e86bc 100644 --- a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseControllerTests.java +++ b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseControllerTests.java @@ -353,6 +353,10 @@ public class FunctionalCaseControllerTests extends BaseTest { functionalCaseAddRequest.setName("测试用例新增"); functionalCaseAddRequest.setCaseEditType("STEP"); functionalCaseAddRequest.setModuleId("default_module_id"); + functionalCaseAddRequest.setDescription(""); + functionalCaseAddRequest.setExpectedResult(""); + functionalCaseAddRequest.setTextDescription(""); + functionalCaseAddRequest.setPrerequisite(""); return functionalCaseAddRequest; }