From d13692c67f69f3e1190d2ae9dc95202f9aac7f92 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Wed, 23 Nov 2022 21:03:25 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E7=94=A8=E4=BE=8B=E5=AF=BC=E5=85=A5=E6=9C=89?= =?UTF-8?q?=E5=90=8C=E5=90=8D=E7=94=A8=E6=88=B7=E5=AF=BC=E5=85=A5=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1020200 --user=陈建星 [测试跟踪] github#20008自定义member字段校验CustomFieldMemberValidator不支持姓名相同的用户 https://www.tapd.cn/55049933/s/1303490 --- .../validate/CustomFieldMemberValidator.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test-track/backend/src/main/java/io/metersphere/validate/CustomFieldMemberValidator.java b/test-track/backend/src/main/java/io/metersphere/validate/CustomFieldMemberValidator.java index 17759fcdc7..16b2d19d0a 100644 --- a/test-track/backend/src/main/java/io/metersphere/validate/CustomFieldMemberValidator.java +++ b/test-track/backend/src/main/java/io/metersphere/validate/CustomFieldMemberValidator.java @@ -9,6 +9,7 @@ import io.metersphere.i18n.Translator; import io.metersphere.service.BaseUserService; import org.apache.commons.lang3.StringUtils; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -22,8 +23,13 @@ public class CustomFieldMemberValidator extends AbstractCustomFieldValidator { this.isKVOption = true; BaseUserService userService = CommonBeanFactory.getBean(BaseUserService.class); List memberOption = userService.getProjectMemberOption(SessionUtils.getCurrentProjectId()); - userIdMap = memberOption.stream().collect(Collectors.toMap(user -> user.getId().toLowerCase(), User::getId)); - userNameMap = memberOption.stream().collect(Collectors.toMap(user -> user.getName().toLowerCase(), User::getId)); + userIdMap = memberOption.stream() + .collect( + Collectors.toMap(user -> user.getId().toLowerCase(), User::getId) + ); + userNameMap = new HashMap<>(); + memberOption.stream() + .forEach(user -> userNameMap.put(user.getName().toLowerCase(), user.getId())); } @Override