fix(测试计划): 多选成员导出值转换
This commit is contained in:
parent
e29fdbfb88
commit
d370961a28
|
@ -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<String> 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<String> 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)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<String> result = new ArrayList<>();
|
||||
Map<String, String> 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)));
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Reference in New Issue