Skip to content

Commit

Permalink
feat:支持管理员查看项目成员 #9620
Browse files Browse the repository at this point in the history
  • Loading branch information
fcfang123 committed Aug 5, 2024
1 parent 5126707 commit 0ce0c71
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -476,10 +476,10 @@ class AuthResourceGroupMemberDao {
projectCode: String,
memberId: String,
iamTemplateIds: List<String>,
resourceType: String?,
resourceType: String? = null,
iamGroupIds: List<Int>? = null,
offset: Int?,
limit: Int?
offset: Int? = null,
limit: Int? = null
): List<AuthResourceGroupMember> {
val conditions = buildMemberGroupCondition(
projectCode = projectCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import com.tencent.devops.common.api.exception.ErrorCodeException
import com.tencent.devops.common.api.model.SQLPage
import com.tencent.devops.common.api.util.DateTimeUtil
import com.tencent.devops.common.api.util.PageUtil
import com.tencent.devops.common.api.util.timestamp
import com.tencent.devops.common.api.util.timestampmilli
import com.tencent.devops.common.auth.api.AuthResourceType
import com.tencent.devops.common.auth.api.pojo.BkAuthGroup
Expand Down Expand Up @@ -862,6 +863,7 @@ class RbacPermissionResourceMemberService constructor(
} else {
// 永久期限 不允许再续期
val groupCountOfPermanentExpiredTime = listMemberGroupsDetails(
projectCode = projectCode,
memberId = conditionReq.targetMember.id,
memberType = conditionReq.targetMember.type,
groupIds = groupIdsOfDirectJoined
Expand Down Expand Up @@ -1027,6 +1029,7 @@ class RbacPermissionResourceMemberService constructor(
).first
val targetMember = conditionReq.targetMember
val memberGroupsDetailsList = listMemberGroupsDetails(
projectCode = projectCode,
memberId = targetMember.id,
memberType = targetMember.type,
groupIds = groupIds
Expand Down Expand Up @@ -1131,6 +1134,7 @@ class RbacPermissionResourceMemberService constructor(
}

private fun listMemberGroupsDetails(
projectCode: String,
memberId: String,
memberType: String,
groupIds: List<Int>
Expand All @@ -1141,11 +1145,30 @@ class RbacPermissionResourceMemberService constructor(
CompletableFuture.supplyAsync(
{
memberGroupsDetailsList.addAll(
iamV2ManagerService.listMemberGroupsDetails(
memberType,
memberId,
it.joinToString(",")
)
// 若离职,则从数据库获取用户加入组的过期时间,调用iam接口会报错。
// 虽然数据库的过期时间可能不是最新的。
if (memberType == ManagerScopesEnum.getType(ManagerScopesEnum.USER) &&
deptService.isUserDeparted(userId = memberId)) {
val records = authResourceGroupMemberDao.listMemberGroupDetail(
dslContext = dslContext,
projectCode = projectCode,
memberId = memberId,
iamTemplateIds = emptyList(),
iamGroupIds = it
)
records.map { record ->
MemberGroupDetailsResponse().apply {
id = record.iamGroupId
expiredAt = record.expiredTime.timestamp()
}
}
} else {
iamV2ManagerService.listMemberGroupsDetails(
memberType,
memberId,
it.joinToString(",")
)
}
)
}, executorService
)
Expand Down

0 comments on commit 0ce0c71

Please sign in to comment.