From 4530788d668b4667109408bf49db1e4950b3bb70 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Tue, 4 Jun 2024 19:12:02 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=94=A8=E4=BE=8B=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E8=84=91=E5=9B=BE=E8=87=AA=E5=AE=9A=E4=B9=89=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/FunctionalCaseMinderService.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseMinderService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseMinderService.java index 2da22b3bd1..6f498b1bed 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseMinderService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseMinderService.java @@ -930,21 +930,19 @@ public class FunctionalCaseMinderService { private List addCustomFields(FunctionalCaseChangeRequest functionalCaseChangeRequest, String caseId, FunctionalCaseCustomFieldMapper caseCustomFieldMapper, Map defaultValueMap) { List customFields = functionalCaseChangeRequest.getCustomFields(); - List caseCustomFields; - if (CollectionUtils.isNotEmpty(customFields)) { - customFields = customFields.stream().distinct().collect(Collectors.toList()); - caseCustomFields = saveCustomField(caseId, caseCustomFieldMapper, customFields); - } else { - List customFieldDTOs = new ArrayList<>(); - defaultValueMap.forEach((k,v)->{ + List list = customFields.stream().map(CaseCustomFieldDTO::getFieldId).toList(); + List customFieldDTOs = new ArrayList<>(); + defaultValueMap.forEach((k, v) -> { + if (!list.contains(k)) { CaseCustomFieldDTO customFieldDTO = new CaseCustomFieldDTO(); customFieldDTO.setFieldId(k); customFieldDTO.setValue(v.toString()); customFieldDTOs.add(customFieldDTO); - }); - caseCustomFields = saveCustomField(caseId, caseCustomFieldMapper, customFieldDTOs); - } - return caseCustomFields; + } + }); + customFields.addAll(customFieldDTOs); + customFields = customFields.stream().distinct().collect(Collectors.toList()); + return saveCustomField(caseId, caseCustomFieldMapper, customFields); } private List saveCustomField(String caseId, FunctionalCaseCustomFieldMapper caseCustomFieldMapper, List customFields) {