Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug:查询部门信息接口 返回字段变动导致异常 #11151 #11152

Merged
merged 3 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -271,6 +273,7 @@ class AuthDeptServiceImpl @Autowired constructor(
)
}

@Suppress("NestedBlockDepth")
override fun listMemberInfos(
memberIds: List<String>,
memberType: ManagerScopesEnum
Expand All @@ -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)
}
}
}
Expand Down Expand Up @@ -327,6 +333,7 @@ class AuthDeptServiceImpl @Autowired constructor(
)
getUserInfo(userSearch).results.map { it.toUserAndDeptInfoVo() }
}

ManagerScopesEnum.DEPARTMENT -> {
val deptSearch = SearchUserAndDeptEntity(
bk_app_code = appCode!!,
Expand All @@ -338,6 +345,7 @@ class AuthDeptServiceImpl @Autowired constructor(
)
getDeptInfo(deptSearch).results.map { it.toUserAndDeptInfoVo() }
}

else -> emptyList()
}
return memberInfos
Expand Down
Loading