diff --git a/backend/src/main/java/io/metersphere/api/service/APITestService.java b/backend/src/main/java/io/metersphere/api/service/APITestService.java index 8e7aca446a..e0d6ba4091 100644 --- a/backend/src/main/java/io/metersphere/api/service/APITestService.java +++ b/backend/src/main/java/io/metersphere/api/service/APITestService.java @@ -520,7 +520,6 @@ public class APITestService { //HTTPSamplerProxy, 进行附件转化: 1.elementProp里去掉路径; 2。elementProp->filePath获取路径并读出来 attachmentFilePathList.addAll(this.parseAttachmentFileInfo(element)); } - //如果存在证书文件,也要匹配出来 attachmentFilePathList.addAll(this.parseAttachmentFileInfo(innerHashTreeElement)); } @@ -535,7 +534,10 @@ public class APITestService { //处理附件 Map attachmentFiles = new HashMap<>(); - + //去重处理 + if(!CollectionUtils.isEmpty(attachmentFilePathList)){ + attachmentFilePathList = attachmentFilePathList.stream().distinct().collect(Collectors.toList()); + } List fileMetadataList = new ArrayList<>(); for (String filePath: attachmentFilePathList) { File file = new File(filePath); @@ -555,8 +557,8 @@ public class APITestService { return returnDTO; } - private List parseAttachmentFileInfo(Element parentHashTreeElement) { - List attachmentFilePathList = new ArrayList<>(); +private List parseAttachmentFileInfo(Element parentHashTreeElement) { + List attachmentFilePathList = new ArrayList<>(); List parentElementList = parentHashTreeElement.elements(); for (Element parentElement: parentElementList) { String qname = parentElement.getQName().getName(); diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanApiCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanApiCaseMapper.xml index 76eb7a69f2..4418bade0d 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanApiCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanApiCaseMapper.xml @@ -24,6 +24,7 @@ AND t.api_case_id IN ( SELECT id FROM api_test_case WHERE status IS NULL OR status != 'Trash' ) + ORDER BY `order` DESC