fix: 调整同 workspace 下 user 不能重复

This commit is contained in:
zhangshuai
2024-09-05 15:21:06 +08:00
parent 5d77111530
commit b7e3048e64

View File

@@ -59,9 +59,14 @@ public class WorkspaceMemberServiceImpl extends ServiceImpl<WorkspaceMemberDao,
if (T.StrUtil.equalsIgnoreCase(workspaceId, "1")) {
throw new ASWException(RCode.WORKSPACE_BUILT_IN);
}
long count = memberList.stream().map(x -> x.getUserId()).distinct().count();
if (count != memberList.size()) {
throw new ASWException(RCode.WORKSPACE_MEMBER_USER_ID_REPEAT);
List userIdList = memberList.stream().map(x -> x.getUserId()).toList();
List<WorkspaceMemberEntity> memberEntityList = workspaceMemberService.list(new LambdaQueryWrapper<WorkspaceMemberEntity>().eq(WorkspaceMemberEntity::getWorkspaceId, workspaceId));
if (T.CollectionUtil.isNotEmpty(memberList)){
memberEntityList = memberEntityList.stream().filter(x -> userIdList.contains(x.getUserId())).toList();
if (T.CollectionUtil.isNotEmpty(memberEntityList)) {
throw new ASWException(RCode.WORKSPACE_MEMBER_USER_ID_REPEAT);
}
}
List<String> userIds = userService.list().stream().map(x -> x.getId()).toList();
List<String> roleIds = roleService.list().stream().map(x -> x.getId()).toList();