diff --git a/src/backend/ci/core/auth/api-auth/src/main/kotlin/com/tencent/devops/auth/api/service/ServiceMonitorSpaceResource.kt b/src/backend/ci/core/auth/api-auth/src/main/kotlin/com/tencent/devops/auth/api/service/ServiceMonitorSpaceResource.kt index 24996c508da..e8efb798c06 100644 --- a/src/backend/ci/core/auth/api-auth/src/main/kotlin/com/tencent/devops/auth/api/service/ServiceMonitorSpaceResource.kt +++ b/src/backend/ci/core/auth/api-auth/src/main/kotlin/com/tencent/devops/auth/api/service/ServiceMonitorSpaceResource.kt @@ -58,6 +58,14 @@ interface ServiceMonitorSpaceResource { projectCode: String ): Result + @Operation(summary = "获取监控空间业务id") + @POST + @Path("/listMonitorSpaceBizIds") + fun listMonitorSpaceBizIds( + @Parameter(description = "项目ID列表", required = false) + projectCodes: List + ): Result> + @POST @Path("/migrateMonitorResource") @Operation(summary = "迁移监控空间权限资源") diff --git a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/dao/AuthMonitorSpaceDao.kt b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/dao/AuthMonitorSpaceDao.kt index 6d3dcf08b20..61b59c435b0 100644 --- a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/dao/AuthMonitorSpaceDao.kt +++ b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/dao/AuthMonitorSpaceDao.kt @@ -40,6 +40,19 @@ class AuthMonitorSpaceDao { } } + fun list( + dslContext: DSLContext, + projectCodes: List + ): Map { + return with(TAuthMonitorSpace.T_AUTH_MONITOR_SPACE) { + dslContext.select(PROJECT_CODE, SPACE_BIZ_ID) + .from(this) + .where(PROJECT_CODE.`in`(projectCodes)) + .fetch() + .map { Pair(it.value1(), it.value2()) }.toMap() + } + } + fun update( dslContext: DSLContext, projectCode: String, diff --git a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/provider/rbac/service/RbacPermissionAuthMonitorSpaceService.kt b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/provider/rbac/service/RbacPermissionAuthMonitorSpaceService.kt index f194d1cefed..c6d316f6db0 100644 --- a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/provider/rbac/service/RbacPermissionAuthMonitorSpaceService.kt +++ b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/provider/rbac/service/RbacPermissionAuthMonitorSpaceService.kt @@ -143,6 +143,13 @@ class RbacPermissionAuthMonitorSpaceService constructor( return "-${dbMonitorSpaceRecord.spaceBizId}" } + override fun listMonitorSpaceBizIds(projectCode: List): Map { + return authMonitorSpaceDao.list( + dslContext = dslContext, + projectCodes = projectCode + ).mapValues { "-${it.value}" } + } + private fun updateMonitorSpace( projectCode: String, monitorSpaceUpdateInfo: MonitorSpaceUpdateInfo, diff --git a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/provider/sample/service/SampleAuthMonitorSpaceService.kt b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/provider/sample/service/SampleAuthMonitorSpaceService.kt index 7c61b104186..3a00e83ab7c 100644 --- a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/provider/sample/service/SampleAuthMonitorSpaceService.kt +++ b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/provider/sample/service/SampleAuthMonitorSpaceService.kt @@ -16,6 +16,10 @@ class SampleAuthMonitorSpaceService : AuthMonitorSpaceService { override fun getMonitorSpaceBizId(projectCode: String): String = "" + override fun listMonitorSpaceBizIds(projectCode: List): Map { + return emptyMap() + } + override fun getMonitorSpaceDetail(spaceUid: String): MonitorSpaceDetailVO? = null override fun getMonitorGroupConfig(groupCode: String): String? = null diff --git a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/resources/service/ServiceMonitorSpaceResourceImpl.kt b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/resources/service/ServiceMonitorSpaceResourceImpl.kt index 763b09e70b2..24ecea32600 100644 --- a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/resources/service/ServiceMonitorSpaceResourceImpl.kt +++ b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/resources/service/ServiceMonitorSpaceResourceImpl.kt @@ -43,6 +43,10 @@ class ServiceMonitorSpaceResourceImpl @Autowired constructor( return Result(monitorSpaceService.getMonitorSpaceBizId(projectCode)) } + override fun listMonitorSpaceBizIds(projectCodes: List): Result> { + return Result(monitorSpaceService.listMonitorSpaceBizIds(projectCodes)) + } + override fun migrateMonitorResource( projectCodes: List, asyncMigrateOtherGroup: Boolean? diff --git a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/AuthMonitorSpaceService.kt b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/AuthMonitorSpaceService.kt index 274848ddab7..cab64256ea7 100644 --- a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/AuthMonitorSpaceService.kt +++ b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/AuthMonitorSpaceService.kt @@ -27,6 +27,11 @@ interface AuthMonitorSpaceService { */ fun getMonitorSpaceBizId(projectCode: String): String + /** + * 获取监控空间业务id列表 + * */ + fun listMonitorSpaceBizIds(projectCode: List): Map + /** * 获取监控空间详情 */ diff --git a/src/backend/ci/core/common/common-auth/common-auth-api/src/main/kotlin/com/tencent/devops/common/auth/api/pojo/ProjectConditionDTO.kt b/src/backend/ci/core/common/common-auth/common-auth-api/src/main/kotlin/com/tencent/devops/common/auth/api/pojo/ProjectConditionDTO.kt index e11c6c31e40..baa58c16a50 100644 --- a/src/backend/ci/core/common/common-auth/common-auth-api/src/main/kotlin/com/tencent/devops/common/auth/api/pojo/ProjectConditionDTO.kt +++ b/src/backend/ci/core/common/common-auth/common-auth-api/src/main/kotlin/com/tencent/devops/common/auth/api/pojo/ProjectConditionDTO.kt @@ -32,5 +32,7 @@ data class ProjectConditionDTO( @get:Schema(title = "是否启用") val enabled: Boolean? = null, @get:Schema(title = "渠道代码") - val channelCode: String? = null + val channelCode: String? = null, + @get:Schema(title = "remoteDev相关") + val queryRemoteDevFlag: Boolean? = null ) diff --git a/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/pojo/ProjectByConditionDTO.kt b/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/pojo/ProjectByConditionDTO.kt index fefb3a0d0bb..1df6099eb71 100644 --- a/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/pojo/ProjectByConditionDTO.kt +++ b/src/backend/ci/core/project/api-project/src/main/kotlin/com/tencent/devops/project/pojo/ProjectByConditionDTO.kt @@ -13,5 +13,7 @@ data class ProjectByConditionDTO( @get:Schema(title = "环境路由") val routerTag: String?, @get:Schema(title = "bgId") - val bgId: Long? = null + val bgId: Long? = null, + @get:Schema(title = "remotedev管理员") + val remotedevManager: String? = null ) diff --git a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/dao/ProjectDao.kt b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/dao/ProjectDao.kt index 75b337443c8..4a1d18dbca1 100644 --- a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/dao/ProjectDao.kt +++ b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/dao/ProjectDao.kt @@ -196,6 +196,9 @@ class ProjectDao { ) } } + if (queryRemoteDevFlag == true) { + conditions.add(JooqUtils.jsonExtractAny(PROPERTIES, "\$.remotedev").isTrue) + } } } return conditions diff --git a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/impl/AbsProjectServiceImpl.kt b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/impl/AbsProjectServiceImpl.kt index d7d4d47c682..31bed594fb2 100644 --- a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/impl/AbsProjectServiceImpl.kt +++ b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/impl/AbsProjectServiceImpl.kt @@ -1044,6 +1044,7 @@ abstract class AbsProjectServiceImpl @Autowired constructor( limit: Int, offset: Int ): List { + logger.info("list projects by condition:$projectConditionDTO|$limit|$offset") return projectDao.listProjectsByCondition( dslContext = dslContext, projectConditionDTO = projectConditionDTO, @@ -1055,7 +1056,12 @@ abstract class AbsProjectServiceImpl @Autowired constructor( englishName = it.englishName, permission = true, routerTag = buildRouterTag(it.routerTag), - bgId = it.bgId + bgId = it.bgId, + remotedevManager = it.properties?.let { properties -> + JsonUtil.to( + properties, ProjectProperties::class.java + ) + }?.remotedevManager ) } }