diff --git a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/common/Constants.kt b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/common/Constants.kt index dd56d40fc8e..e19021fbf9c 100644 --- a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/common/Constants.kt +++ b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/common/Constants.kt @@ -29,7 +29,7 @@ package com.tencent.devops.auth.common object Constants { const val SUPER_MANAGER = -1 - const val DEPT_LABEL = "id,name,parent,enabled,has_children" + const val DEPT_LABEL = "id,name,parent,enabled" const val USER_LABEL = "id,username,display_name,enabled,departments,extras" const val USER_NAME_AND_DISPLAY_NAME_LABEL = "id,username,display_name" const val LEVEL = "level" diff --git a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/AuthDeptServiceImpl.kt b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/AuthDeptServiceImpl.kt index bedb4278b84..2c95c78278d 100644 --- a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/AuthDeptServiceImpl.kt +++ b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/AuthDeptServiceImpl.kt @@ -180,12 +180,14 @@ class AuthDeptServiceImpl @Autowired constructor( ) } } + ManagerScopesEnum.DEPARTMENT -> { val deptInfos = getDeptInfo(deptSearch) deptInfos.results.forEach { it.toUserAndDeptInfoVo() } } + ManagerScopesEnum.ALL -> { val userInfos = getUserInfo(userSearch) userInfos.results.forEach { @@ -271,6 +273,7 @@ class AuthDeptServiceImpl @Autowired constructor( ) } + @Suppress("NestedBlockDepth") override fun listMemberInfos( memberIds: List, memberType: ManagerScopesEnum @@ -280,12 +283,15 @@ class AuthDeptServiceImpl @Autowired constructor( if (membersNotInCache.isNotEmpty()) { val fetchedMembers = fetchMemberInfos(membersNotInCache, memberType) - fetchedMembers.forEach { memberInfoCache.put(it.name, it) } - - if (memberType == ManagerScopesEnum.USER) { - val departedMembers = membersNotInCache.subtract(fetchedMembers.map { it.name }.toSet()) - if (departedMembers.isNotEmpty()) { - departedMembersCache.addAll(departedMembers) + fetchedMembers.forEach { + if (it.type == ManagerScopesEnum.USER) { + memberInfoCache.put(it.name, it) + val departedMembers = membersNotInCache.subtract(fetchedMembers.map { it.name }.toSet()) + if (departedMembers.isNotEmpty()) { + departedMembersCache.addAll(departedMembers) + } + } else { + memberInfoCache.put(it.id.toString(), it) } } } @@ -327,6 +333,7 @@ class AuthDeptServiceImpl @Autowired constructor( ) getUserInfo(userSearch).results.map { it.toUserAndDeptInfoVo() } } + ManagerScopesEnum.DEPARTMENT -> { val deptSearch = SearchUserAndDeptEntity( bk_app_code = appCode!!, @@ -338,6 +345,7 @@ class AuthDeptServiceImpl @Autowired constructor( ) getDeptInfo(deptSearch).results.map { it.toUserAndDeptInfoVo() } } + else -> emptyList() } return memberInfos