From 4e91ace3ceb342c074ed0c3231dd0ff1e0699252 Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Wed, 14 Aug 2024 17:41:56 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E7=9B=B4=E5=9C=A8=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E4=B8=AD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../excel/listener/FunctionalCaseCheckEventListener.java | 2 +- .../excel/listener/FunctionalCaseImportEventListener.java | 2 +- .../excel/validate/CustomFieldMemberValidator.java | 6 ++++-- .../excel/validate/CustomFieldValidatorFactory.java | 5 +++-- .../functional/service/FunctionalCaseFileService.java | 2 +- .../functional/xmind/parser/XMindCaseParser.java | 2 +- .../metersphere/functional/xmind/utils/XmindExportUtil.java | 2 +- 7 files changed, 12 insertions(+), 9 deletions(-) diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/excel/listener/FunctionalCaseCheckEventListener.java b/backend/services/case-management/src/main/java/io/metersphere/functional/excel/listener/FunctionalCaseCheckEventListener.java index 2b47511515..93f7ea3c4e 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/excel/listener/FunctionalCaseCheckEventListener.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/excel/listener/FunctionalCaseCheckEventListener.java @@ -71,7 +71,7 @@ public class FunctionalCaseCheckEventListener extends AnalysisEventListener i)); - customFieldValidatorMap = CustomFieldValidatorFactory.getValidatorMap(); + customFieldValidatorMap = CustomFieldValidatorFactory.getValidatorMap(request.getProjectId()); functionalCaseService = CommonBeanFactory.getBean(FunctionalCaseService.class); } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/excel/listener/FunctionalCaseImportEventListener.java b/backend/services/case-management/src/main/java/io/metersphere/functional/excel/listener/FunctionalCaseImportEventListener.java index 09c303122b..090e79a57a 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/excel/listener/FunctionalCaseImportEventListener.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/excel/listener/FunctionalCaseImportEventListener.java @@ -95,7 +95,7 @@ public class FunctionalCaseImportEventListener extends AnalysisEventListener i)); moduleTree = CommonBeanFactory.getBean(FunctionalCaseModuleService.class).getTree(request.getProjectId()); functionalCaseService = CommonBeanFactory.getBean(FunctionalCaseService.class); - customFieldValidatorMap = CustomFieldValidatorFactory.getValidatorMap(); + customFieldValidatorMap = CustomFieldValidatorFactory.getValidatorMap(request.getProjectId()); lastPos = new AtomicLong(pos); this.user = user; diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/excel/validate/CustomFieldMemberValidator.java b/backend/services/case-management/src/main/java/io/metersphere/functional/excel/validate/CustomFieldMemberValidator.java index e16b977890..b86837889e 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/excel/validate/CustomFieldMemberValidator.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/excel/validate/CustomFieldMemberValidator.java @@ -7,7 +7,6 @@ import io.metersphere.sdk.util.CommonBeanFactory; import io.metersphere.sdk.util.Translator; import io.metersphere.system.domain.User; import io.metersphere.system.dto.sdk.TemplateCustomFieldDTO; -import io.metersphere.system.utils.SessionUtils; import org.apache.commons.lang3.StringUtils; import java.util.HashMap; @@ -25,9 +24,12 @@ public class CustomFieldMemberValidator extends AbstractCustomFieldValidator { protected Map userNameMap; public CustomFieldMemberValidator() { + } + + public CustomFieldMemberValidator(String projectId) { this.isKVOption = true; ProjectApplicationService projectApplicationService = CommonBeanFactory.getBean(ProjectApplicationService.class); - List memberOption = projectApplicationService.getProjectUserList(SessionUtils.getCurrentProjectId()); + List memberOption = projectApplicationService.getProjectUserList(projectId); userIdMap = memberOption.stream() .collect( Collectors.toMap(user -> user.getId().toLowerCase(), User::getId) diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/excel/validate/CustomFieldValidatorFactory.java b/backend/services/case-management/src/main/java/io/metersphere/functional/excel/validate/CustomFieldValidatorFactory.java index 5324acb6ef..b43f12ac67 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/excel/validate/CustomFieldValidatorFactory.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/excel/validate/CustomFieldValidatorFactory.java @@ -11,7 +11,8 @@ import java.util.HashMap; public class CustomFieldValidatorFactory { private static final HashMap validatorMap = new HashMap<>(); - public static HashMap getValidatorMap() { + + public static HashMap getValidatorMap(String projectId) { validatorMap.put(CustomFieldType.SELECT.name(), new CustomFieldSelectValidator()); validatorMap.put(CustomFieldType.SELECT.name(), new CustomFieldSelectValidator()); validatorMap.put(CustomFieldType.RADIO.name(), new CustomFieldSelectValidator()); @@ -27,7 +28,7 @@ public class CustomFieldValidatorFactory { validatorMap.put(CustomFieldType.DATE.name(), new CustomFieldDateValidator()); validatorMap.put(CustomFieldType.DATETIME.name(), new CustomFieldDateTimeValidator()); - validatorMap.put(CustomFieldType.MEMBER.name(), new CustomFieldMemberValidator()); + validatorMap.put(CustomFieldType.MEMBER.name(), new CustomFieldMemberValidator(projectId)); validatorMap.put(CustomFieldType.MULTIPLE_MEMBER.name(), new CustomFieldMultipleMemberValidator()); validatorMap.put(CustomFieldType.INT.name(), new CustomFieldIntegerValidator()); diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseFileService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseFileService.java index 0a5163cd4c..738614823a 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseFileService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseFileService.java @@ -755,7 +755,7 @@ public class FunctionalCaseFileService { if (CollectionUtils.isEmpty(request.getCustomFields())) { return; } - HashMap customFieldValidatorMap = CustomFieldValidatorFactory.getValidatorMap(); + HashMap customFieldValidatorMap = CustomFieldValidatorFactory.getValidatorMap(request.getProjectId()); Map customFieldsMap = templateCustomFields.stream().collect(Collectors.toMap(TemplateCustomFieldDTO::getFieldId, i -> i)); Map caseFieldvalueMap = functionalCaseCustomFields.stream().collect(Collectors.toMap(FunctionalCaseCustomField::getFieldId, FunctionalCaseCustomField::getValue)); Map map = new HashMap<>(); diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/xmind/parser/XMindCaseParser.java b/backend/services/case-management/src/main/java/io/metersphere/functional/xmind/parser/XMindCaseParser.java index f101af13ce..19c0395738 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/xmind/parser/XMindCaseParser.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/xmind/parser/XMindCaseParser.java @@ -72,7 +72,7 @@ public class XMindCaseParser { customFieldsMap = customFields.stream().collect(Collectors.toMap(TemplateCustomFieldDTO::getFieldName, i -> i)); functionalCaseService = CommonBeanFactory.getBean(FunctionalCaseService.class); moduleTree = CommonBeanFactory.getBean(FunctionalCaseModuleService.class).getTree(request.getProjectId()); - customFieldValidatorMap = CustomFieldValidatorFactory.getValidatorMap(); + customFieldValidatorMap = CustomFieldValidatorFactory.getValidatorMap(request.getProjectId()); lastPos = new AtomicLong(pos); this.user = user; process = new DetailUtil(); diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/xmind/utils/XmindExportUtil.java b/backend/services/case-management/src/main/java/io/metersphere/functional/xmind/utils/XmindExportUtil.java index 039a12dbd6..0dc1e4cea2 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/xmind/utils/XmindExportUtil.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/xmind/utils/XmindExportUtil.java @@ -518,7 +518,7 @@ public class XmindExportUtil { //自定义字段 Map customColumnsMap = request.getCustomFields().stream().collect(Collectors.toMap(FunctionalCaseHeader::getId, FunctionalCaseHeader::getName)); Map temCustomFieldsMap = templateCustomFields.stream().collect(Collectors.toMap(TemplateCustomFieldDTO::getFieldId, i -> i)); - HashMap customFieldValidatorMap = CustomFieldValidatorFactory.getValidatorMap(); + HashMap customFieldValidatorMap = CustomFieldValidatorFactory.getValidatorMap(request.getProjectId()); customColumnsMap.forEach((k, v) -> { if (customFieldMap.containsKey(k) && temCustomFieldsMap.containsKey(k)) {