Skip to content

Commit

Permalink
feat:用户个人视角 权限管理优化 #11138
Browse files Browse the repository at this point in the history
  • Loading branch information
fcfang123 committed Dec 17, 2024
1 parent 32d6287 commit 749aaf4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,7 @@ interface UserProjectResource {
sortType: ProjectSortType?,
@Parameter(description = "排序规则", required = false)
@QueryParam("collation")
collation: ProjectCollation?,
@Parameter(description = "是否查询授权相关项目", required = false)
@QueryParam("queryAuthorization")
queryAuthorization: Boolean?
collation: ProjectCollation?
): Result<List<ProjectVO>>

@GET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ class UserProjectResourceImpl @Autowired constructor(
enabled: Boolean?,
unApproved: Boolean?,
sortType: ProjectSortType?,
collation: ProjectCollation?,
queryAuthorization: Boolean?
collation: ProjectCollation?
): Result<List<ProjectVO>> {
return Result(
projectService.list(
Expand All @@ -79,8 +78,7 @@ class UserProjectResourceImpl @Autowired constructor(
enabled = enabled,
unApproved = unApproved ?: false,
sortType = sortType ?: ProjectSortType.PROJECT_NAME,
collation = collation ?: ProjectCollation.DEFAULT,
queryAuthorization = queryAuthorization
collation = collation ?: ProjectCollation.DEFAULT
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,7 @@ interface ProjectService {
enabled: Boolean? = null,
unApproved: Boolean,
sortType: ProjectSortType? = null,
collation: ProjectCollation? = null,
// 获取授权相关项目(主要用于个人视角界面)
queryAuthorization: Boolean? = false
collation: ProjectCollation? = null
): List<ProjectVO>

fun listProjectsForApply(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import com.fasterxml.jackson.databind.ObjectMapper
import com.tencent.bk.audit.annotations.ActionAuditRecord
import com.tencent.bk.audit.annotations.AuditInstanceRecord
import com.tencent.bk.audit.context.ActionAuditContext
import com.tencent.devops.auth.api.service.ServiceProjectAuthResource
import com.tencent.devops.common.api.enums.SystemModuleEnum
import com.tencent.devops.common.api.exception.ErrorCodeException
import com.tencent.devops.common.api.exception.InvalidParamException
Expand Down Expand Up @@ -810,8 +809,7 @@ abstract class AbsProjectServiceImpl @Autowired constructor(
enabled: Boolean?,
unApproved: Boolean,
sortType: ProjectSortType?,
collation: ProjectCollation?,
queryAuthorization: Boolean?
collation: ProjectCollation?
): List<ProjectVO> {
val startEpoch = System.currentTimeMillis()
var success = false
Expand All @@ -821,17 +819,6 @@ abstract class AbsProjectServiceImpl @Autowired constructor(
userId = userId,
accessToken = accessToken
).toMutableSet()
// 获取授权相关项目,主要用于个人视角权限管理
if (queryAuthorization == true) {
val projectWithAuthorization = try {
client.get(ServiceProjectAuthResource::class).listUserProjects(userId).data ?: emptyList()
} catch (ex: Exception) {
emptyList()
}
projectsWithVisitPermission.apply {
this.addAll(projectWithAuthorization)
}
}

if (projectsWithVisitPermission.isEmpty() && !unApproved) {
return emptyList()
Expand Down

0 comments on commit 749aaf4

Please sign in to comment.