diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/excel/validate/CustomFieldMultipleMemberValidator.java b/backend/services/case-management/src/main/java/io/metersphere/functional/excel/validate/CustomFieldMultipleMemberValidator.java index f5733b6de4..2fbf133722 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/excel/validate/CustomFieldMultipleMemberValidator.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/excel/validate/CustomFieldMultipleMemberValidator.java @@ -15,6 +15,10 @@ import java.util.List; */ public class CustomFieldMultipleMemberValidator extends CustomFieldMemberValidator { + public CustomFieldMultipleMemberValidator(String projectId) { + super(projectId); + } + @Override public void validate(TemplateCustomFieldDTO customField, String value) throws CustomFieldValidateException { validateArrayRequired(customField, value); @@ -54,15 +58,15 @@ public class CustomFieldMultipleMemberValidator extends CustomFieldMemberValidat if (StringUtils.isBlank(keyOrValuesStr)) { return JSON.toJSONString(new ArrayList<>()); } - List keyOrValues = parse2Array(keyOrValuesStr); - - for (int i = 0; i < keyOrValues.size(); i++) { - String item = keyOrValues.get(i).toLowerCase(); - if (userIdEmailMap.containsKey(item)) { - keyOrValues.set(i, userIdEmailMap.get(item)); + List list = JSON.parseArray(keyOrValuesStr); + List result = new ArrayList<>(); + list.forEach(item -> { + if (super.userIdEmailMap.containsKey(item)) { + result.add(userIdEmailMap.get(item)); } - } - return JSON.toJSONString(keyOrValues); + }); + + return String.join(",", JSON.parseArray(JSON.toJSONString(result))); } } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/excel/validate/CustomFieldMultipleSelectValidator.java b/backend/services/case-management/src/main/java/io/metersphere/functional/excel/validate/CustomFieldMultipleSelectValidator.java index a93edadd5a..9e6c3ba781 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/excel/validate/CustomFieldMultipleSelectValidator.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/excel/validate/CustomFieldMultipleSelectValidator.java @@ -56,12 +56,14 @@ public class CustomFieldMultipleSelectValidator extends CustomFieldSelectValidat if (StringUtils.isBlank(keyOrValuesStr) || StringUtils.equals(keyOrValuesStr, "[]")) { return StringUtils.EMPTY; } - String keyOrValues = String.join(",", JSON.parseArray(keyOrValuesStr)); + List list = JSON.parseArray(keyOrValuesStr); List result = new ArrayList<>(); Map optionValueMap = customField.getOptions().stream().collect(Collectors.toMap(CustomFieldOption::getValue, CustomFieldOption::getText)); - if (optionValueMap.containsKey(keyOrValues)) { - result.add(optionValueMap.get(keyOrValues)); - } + list.forEach(item -> { + if (optionValueMap.containsKey(item)) { + result.add(optionValueMap.get(item)); + } + }); return String.join(",", JSON.parseArray(JSON.toJSONString(result))); } 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 b43f12ac67..43afe654e5 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 @@ -29,7 +29,7 @@ public class CustomFieldValidatorFactory { validatorMap.put(CustomFieldType.DATETIME.name(), new CustomFieldDateTimeValidator()); validatorMap.put(CustomFieldType.MEMBER.name(), new CustomFieldMemberValidator(projectId)); - validatorMap.put(CustomFieldType.MULTIPLE_MEMBER.name(), new CustomFieldMultipleMemberValidator()); + validatorMap.put(CustomFieldType.MULTIPLE_MEMBER.name(), new CustomFieldMultipleMemberValidator(projectId)); validatorMap.put(CustomFieldType.INT.name(), new CustomFieldIntegerValidator()); validatorMap.put(CustomFieldType.FLOAT.name(), new CustomFieldFloatValidator());