fix(用户权限): 组织开通工作台时,未选择的用户将移出组织

This commit is contained in:
OTTO 2024-09-03 09:17:21 +08:00
parent 67bf5caecf
commit 7a61d513b4
1 changed files with 25 additions and 0 deletions

View File

@ -241,6 +241,12 @@ public class PmsCommonAsyncServiceImpl implements IPmsCommonAsyncService {
return teamId;
}
/**
* 同步Forge组织中成员到工作台中未同步的用户需在Forge中移除
*
* @param enterpriseId 企业id
* @param gitLinkUserToEnterpriseInputVoList 需要同步到企业的用户列表
*/
@Override
public void syncGitlinkOrganizationUserToPmsEnterprise(Long enterpriseId, List<GitLinkUserToEnterpriseInputVo> gitLinkUserToEnterpriseInputVoList) {
CustomExecutorFactory.threadPoolExecutor.execute(() -> {
@ -260,6 +266,25 @@ public class PmsCommonAsyncServiceImpl implements IPmsCommonAsyncService {
Long pmsProjectAdminTeamId = getGitlinkOrgTeamIdByTeamKey(pmsEnterprise, PmsConstants.GITLINK_ORGANIZATION_TEAM_ADMIN);
Long pmsUserTeamId = getGitlinkOrgTeamIdByTeamKey(pmsEnterprise, PmsConstants.GITLINK_ORGANIZATION_TEAM_WRITE);
// 获取原Owner团队中成员列表
List<GitLinkUserSimpleInfoVo> oldOwnerUserList = pmsCommonService.getAllGitlinkUsersByOrgTeam(pmsEnterprise.getEnterpriseIdentifier(), ownerTeamId);
List<Long> newOwnerUserIdList = gitLinkUserToEnterpriseInputVoList
.stream()
.filter(x -> x.getRoleKey().equals(SystemRole.PMS_ORG_ADMIN.getRoleKey()))
.map(GitLinkUserToEnterpriseInputVo::getUserId)
.collect(Collectors.toList());
// 删除原Owner团队中不在新Owner团队中的成员
List<GitLinkUserSimpleInfoVo> removeUserIdList = oldOwnerUserList
.stream()
.filter(x -> !newOwnerUserIdList.contains(x.getUserId()))
.collect(Collectors.toList());
for (GitLinkUserSimpleInfoVo gitLinkUserSimpleInfoVo : removeUserIdList) {
gitLinkRequestHelper.doDelete(
PmsGitLinkRequestUrl.DELETE_USER_FROM_ORGANIZATION_TEAM(pmsEnterprise.getEnterpriseIdentifier(), ownerTeamId, gitLinkUserSimpleInfoVo.getUsername()));
}
JSONObject addUserToTeam = new JSONObject();
// 将用户添加到微服务部门中并调整到对应团队中
for (GitLinkUserToEnterpriseInputVo gitLinkUserToEnterpriseInputVo : gitLinkUserToEnterpriseInputVoList) {