From cb34ba589baa3a67fc83b1aee294d4a64b3b1205 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Mon, 17 Oct 2022 16:16:24 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=A1=B9=E7=9B=AE=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=B7=BB=E5=8A=A0=E6=88=90=E5=91=98=E5=88=B0?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E7=A9=BA=E9=97=B4=E5=85=B1=E4=BA=AB=E7=9A=84?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=BB=84=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1018128 --user=李玉号 【项目设置】项目成员中添加成员-该成员选择一个新建的用户组-添加不成功 https://www.tapd.cn/55049933/s/1264452 --- .../main/java/io/metersphere/service/UserService.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/system-setting/backend/src/main/java/io/metersphere/service/UserService.java b/system-setting/backend/src/main/java/io/metersphere/service/UserService.java index afb6595549..1c39a9b5c2 100644 --- a/system-setting/backend/src/main/java/io/metersphere/service/UserService.java +++ b/system-setting/backend/src/main/java/io/metersphere/service/UserService.java @@ -1255,6 +1255,10 @@ public class UserService { List existGroupIds = this.getUserExistSourceGroup(userId, sourceId); toAddGroupIds.removeAll(existGroupIds); toAddGroupIds.retainAll(dbOptionalGroupIds); + if (CollectionUtils.isEmpty(toAddGroupIds)) { + LogUtil.warn("group ids not in db or not has permission, please check!"); + continue; + } for (String groupId : toAddGroupIds) { UserGroup userGroup = new UserGroup(UUID.randomUUID().toString(), userId, groupId, sourceId, System.currentTimeMillis(), System.currentTimeMillis()); @@ -1280,6 +1284,12 @@ public class UserService { private List getGroupIdsByType(String type, String sourceId) { // 某项目/工作空间下能查看到的用户组 List scopeList = Arrays.asList("global", sourceId); + if (StringUtils.equals(type, "PROJECT")) { + Project project = projectMapper.selectByPrimaryKey(sourceId); + if (project != null) { + scopeList = Arrays.asList("global", sourceId, project.getWorkspaceId()); + } + } GroupExample groupExample = new GroupExample(); groupExample.createCriteria().andScopeIdIn(scopeList) .andTypeEqualTo(type);