Skip to content

Commit

Permalink
feat: IAM回调添加项目审批人 TencentBlueKing#5228
Browse files Browse the repository at this point in the history
  • Loading branch information
fitzcao committed Sep 24, 2021
1 parent 63bdb78 commit 8c23064
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class BkAuthPermissionProjectService : PermissionProjectService {
return true
}

override fun createProjectUser(userId: String, projectCode: String, roleName: String): Boolean {
override fun createProjectUser(userId: String, projectCode: String, roleCode: String): Boolean {
return true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class ServiceProjectAuthResourceImpl @Autowired constructor(
permissionProjectService.createProjectUser(
userId = userId,
projectCode = projectCode,
roleName = role
roleCode = role
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ class AuthGroupService @Autowired constructor(
return groupDao.getGroupByName(dslContext, projectCode, groupName)
}

fun getGroupByCode(projectCode: String, groupCode: String): TAuthGroupInfoRecord? {
return groupDao.getGroup(dslContext, projectCode, groupCode)
}

fun bindRelationId(id: Int, relationId: String): Int {
return groupDao.updateRelationId(dslContext, id, relationId)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ interface PermissionProjectService {

fun isProjectUser(userId: String, projectCode: String, group: BkAuthGroup?): Boolean

fun createProjectUser(userId: String, projectCode: String, roleName: String): Boolean
fun createProjectUser(userId: String, projectCode: String, roleCode: String): Boolean

fun getProjectRoles(projectCode: String, projectId: String): List<BKAuthProjectRolesResources>
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,14 @@ abstract class AbsPermissionProjectService @Autowired constructor(
return checkProjectUser
}

override fun createProjectUser(userId: String, projectCode: String, roleName: String): Boolean {
override fun createProjectUser(userId: String, projectCode: String, roleCode: String): Boolean {
val extProjectId = getProjectId(projectCode)
val projectRoles = groupService.getGroupByName(projectCode, roleName)
val projectRoles = groupService.getGroupByCode(projectCode, roleCode)
if (projectRoles == null) {
logger.warn("$projectCode | $roleName group not exists")
throw ParamBlankException("user group $roleName not exists")
logger.warn("$projectCode | $roleCode group not exists")
throw ParamBlankException("user group $roleCode not exists")
}
val managerRole = roleName == BkAuthGroup.MANAGER.value
val managerRole = roleCode == BkAuthGroup.MANAGER.value
val members = mutableListOf<RoleMemberDTO>()
members.add(RoleMemberDTO(type = ManagerScopesEnum.USER, id = userId))
permissionRoleMemberService.createRoleMember(
Expand Down

0 comments on commit 8c23064

Please sign in to comment.