From 884d1a16ae0c321c72918a63e9f6862a2ce063c1 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Mon, 21 Oct 2024 11:25:01 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=90=8C=E6=AD=A5=E5=B9=B6?= =?UTF-8?q?=E5=88=86=E8=A1=A8=E5=AD=98=E5=82=A8=E8=B5=84=E6=BA=90=E7=BB=84?= =?UTF-8?q?=E6=9D=83=E9=99=90=E6=95=B0=E6=8D=AE=20#10964?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RbacPermissionResourceMemberService.kt | 20 +++++++++++-------- .../auth/api/pojo/BkAuthGroupAndUserList.kt | 3 +++ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/provider/rbac/service/RbacPermissionResourceMemberService.kt b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/provider/rbac/service/RbacPermissionResourceMemberService.kt index 227c79adfc0..d5525d3fb69 100644 --- a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/provider/rbac/service/RbacPermissionResourceMemberService.kt +++ b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/provider/rbac/service/RbacPermissionResourceMemberService.kt @@ -466,19 +466,23 @@ class RbacPermissionResourceMemberService( page = 1 } val groupMemberInfoList = iamV2ManagerService.getRoleGroupMemberV2(groupInfo.id, pageInfoDTO).results - val members = mutableListOf() + val nowTimestamp = System.currentTimeMillis() / 1000 - groupMemberInfoList.forEach { memberInfo -> - if (memberInfo.type == ManagerScopesEnum.getType(ManagerScopesEnum.USER) && - memberInfo.expiredAt > nowTimestamp) { - members.add(memberInfo.id) - } - } + val (members, deptInfoList) = groupMemberInfoList + .filter { it.expiredAt > nowTimestamp } + .partition { it.type == ManagerScopesEnum.getType(ManagerScopesEnum.USER) } + return BkAuthGroupAndUserList( displayName = groupInfo.name, roleId = groupInfo.id, roleName = groupInfo.name, - userIdList = members.toSet().toList(), + userIdList = members.map { it.id }, + deptInfoList = deptInfoList.map { memberInfo -> + RoleGroupMemberInfo().apply { + id = memberInfo.id + name = memberInfo.name + } + }, type = "" ) } diff --git a/src/backend/ci/core/common/common-auth/common-auth-api/src/main/kotlin/com/tencent/devops/common/auth/api/pojo/BkAuthGroupAndUserList.kt b/src/backend/ci/core/common/common-auth/common-auth-api/src/main/kotlin/com/tencent/devops/common/auth/api/pojo/BkAuthGroupAndUserList.kt index e7c72313ca7..85836df0c8c 100644 --- a/src/backend/ci/core/common/common-auth/common-auth-api/src/main/kotlin/com/tencent/devops/common/auth/api/pojo/BkAuthGroupAndUserList.kt +++ b/src/backend/ci/core/common/common-auth/common-auth-api/src/main/kotlin/com/tencent/devops/common/auth/api/pojo/BkAuthGroupAndUserList.kt @@ -28,6 +28,7 @@ package com.tencent.devops.common.auth.api.pojo import com.fasterxml.jackson.annotation.JsonProperty +import com.tencent.bk.sdk.iam.dto.manager.RoleGroupMemberInfo data class BkAuthGroupAndUserList( @JsonProperty("display_name") @@ -38,6 +39,8 @@ data class BkAuthGroupAndUserList( val roleName: String, @JsonProperty("user_id_list") val userIdList: List, + @JsonProperty("dept_info_list") + val deptInfoList: List? = null, @JsonProperty("type") val type: String )