fix(项目设置): 无法添加成员到工作空间共享的用户组中

--bug=1018128 --user=李玉号 【项目设置】项目成员中添加成员-该成员选择一个新建的用户组-添加不成功
https://www.tapd.cn/55049933/s/1264452
This commit is contained in:
shiziyuan9527 2022-10-17 16:16:24 +08:00 committed by lyh
parent acb9a7408a
commit cb34ba589b

View File

@ -1255,6 +1255,10 @@ public class UserService {
List<String> existGroupIds = this.getUserExistSourceGroup(userId, sourceId); List<String> existGroupIds = this.getUserExistSourceGroup(userId, sourceId);
toAddGroupIds.removeAll(existGroupIds); toAddGroupIds.removeAll(existGroupIds);
toAddGroupIds.retainAll(dbOptionalGroupIds); 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) { for (String groupId : toAddGroupIds) {
UserGroup userGroup = new UserGroup(UUID.randomUUID().toString(), userId, groupId, UserGroup userGroup = new UserGroup(UUID.randomUUID().toString(), userId, groupId,
sourceId, System.currentTimeMillis(), System.currentTimeMillis()); sourceId, System.currentTimeMillis(), System.currentTimeMillis());
@ -1280,6 +1284,12 @@ public class UserService {
private List<String> getGroupIdsByType(String type, String sourceId) { private List<String> getGroupIdsByType(String type, String sourceId) {
// 某项目/工作空间下能查看到的用户组 // 某项目/工作空间下能查看到的用户组
List<String> scopeList = Arrays.asList("global", sourceId); List<String> 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 groupExample = new GroupExample();
groupExample.createCriteria().andScopeIdIn(scopeList) groupExample.createCriteria().andScopeIdIn(scopeList)
.andTypeEqualTo(type); .andTypeEqualTo(type);