From f5dea6c921fbda1b7edebb06cef5d8c4bd6fe213 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Wed, 24 Aug 2022 16:33:55 +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=87=BA=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=90=8D=E5=BF=BD=E7=95=A5=E5=A4=A7=E5=B0=8F=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1015896 --user=陈建星 【测试跟踪】用户id是小写,导入用例时责任人id填写大写,导入失败 https://www.tapd.cn/55049933/s/1233002 --- .../track/validate/CustomFieldMemberValidator.java | 8 ++++++-- .../validate/CustomFieldMultipleMemberValidator.java | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/io/metersphere/track/validate/CustomFieldMemberValidator.java b/backend/src/main/java/io/metersphere/track/validate/CustomFieldMemberValidator.java index 28a61d79e9..ee2d01fa23 100644 --- a/backend/src/main/java/io/metersphere/track/validate/CustomFieldMemberValidator.java +++ b/backend/src/main/java/io/metersphere/track/validate/CustomFieldMemberValidator.java @@ -22,8 +22,8 @@ public class CustomFieldMemberValidator extends AbstractCustomFieldValidator { this.isKVOption = true; UserService userService = CommonBeanFactory.getBean(UserService.class); List memberOption = userService.getProjectMemberOption(SessionUtils.getCurrentProjectId()); - userIdMap = memberOption.stream().collect(Collectors.toMap(user -> user.getId().toLowerCase(), user -> user.getName().toLowerCase())); - userNameMap = memberOption.stream().collect(Collectors.toMap(user -> user.getName().toLowerCase(), user -> user.getId().toLowerCase())); + userIdMap = memberOption.stream().collect(Collectors.toMap(user -> user.getId().toLowerCase(), User::getId)); + userNameMap = memberOption.stream().collect(Collectors.toMap(user -> user.getName().toLowerCase(), User::getId)); } @Override @@ -41,6 +41,10 @@ public class CustomFieldMemberValidator extends AbstractCustomFieldValidator { @Override public Object parse2Key(String keyOrValue, CustomFieldDao customField) { + keyOrValue = keyOrValue.toLowerCase(); + if (userIdMap.containsKey(keyOrValue)) { + return userIdMap.get(keyOrValue); + } if (userNameMap.containsKey(keyOrValue.toLowerCase())) { return userNameMap.get(keyOrValue.toLowerCase()); } diff --git a/backend/src/main/java/io/metersphere/track/validate/CustomFieldMultipleMemberValidator.java b/backend/src/main/java/io/metersphere/track/validate/CustomFieldMultipleMemberValidator.java index 2e48a00568..0471d0bc2b 100644 --- a/backend/src/main/java/io/metersphere/track/validate/CustomFieldMultipleMemberValidator.java +++ b/backend/src/main/java/io/metersphere/track/validate/CustomFieldMultipleMemberValidator.java @@ -34,6 +34,9 @@ public class CustomFieldMultipleMemberValidator extends CustomFieldMemberValidat for (int i = 0; i < keyOrValues.size(); i++) { String item = keyOrValues.get(i).toLowerCase(); + if (userIdMap.containsKey(item)) { + keyOrValues.set(i, userIdMap.get(item)); + } if (userNameMap.containsKey(item)) { keyOrValues.set(i, userNameMap.get(item)); }