fix(测试跟踪): 功能用例导入有同名用户导入失败

--bug=1020200 --user=陈建星 [测试跟踪] github#20008自定义member字段校验CustomFieldMemberValidator不支持姓名相同的用户 https://www.tapd.cn/55049933/s/1303490
This commit is contained in:
chenjianxing 2022-11-23 21:03:25 +08:00 committed by jianxing
parent de6749a506
commit d13692c67f
1 changed files with 8 additions and 2 deletions

View File

@ -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<User> 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