From eefb6d573102852b1551296a23c2c64c00dac771 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Tue, 3 Dec 2024 11:55:55 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat=EF=BC=9A=E6=9F=A5=E8=AF=A2=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=8E=A5=E5=8F=A3=E4=BC=98=E5=8C=96=20#11276?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/common/auth/api/pojo/ProjectConditionDTO.kt | 4 +++- .../main/kotlin/com/tencent/devops/project/dao/ProjectDao.kt | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) 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/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..d81cca4f897 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 { ) } } + queryRemoteDevFlag?.let { + conditions.add(JooqUtils.jsonExtractAny(PROPERTIES, "\$.remotedev").isTrue) + } } } return conditions From d7845ef8eed0346a0852122ea6cc84cf0cd69b0a Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 4 Dec 2024 15:00:03 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat=EF=BC=9A=E6=9F=A5=E8=AF=A2=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=8E=A5=E5=8F=A3=E4=BC=98=E5=8C=96=20#11276?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/api/service/ServiceMonitorSpaceResource.kt | 8 ++++++++ .../tencent/devops/auth/dao/AuthMonitorSpaceDao.kt | 13 +++++++++++++ .../RbacPermissionAuthMonitorSpaceService.kt | 7 +++++++ .../sample/service/SampleAuthMonitorSpaceService.kt | 4 ++++ .../service/ServiceMonitorSpaceResourceImpl.kt | 4 ++++ .../devops/auth/service/AuthMonitorSpaceService.kt | 5 +++++ .../devops/project/pojo/ProjectByConditionDTO.kt | 4 +++- .../project/service/impl/AbsProjectServiceImpl.kt | 7 ++++++- 8 files changed, 50 insertions(+), 2 deletions(-) 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/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/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..1d70f5eb718 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 @@ -1055,7 +1055,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 ) } } From 72f259516b487d05978ede75b10782a18f3b698b Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 4 Dec 2024 15:35:39 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat=EF=BC=9A=E6=9F=A5=E8=AF=A2=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=8E=A5=E5=8F=A3=E4=BC=98=E5=8C=96=20#11276?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/kotlin/com/tencent/devops/project/dao/ProjectDao.kt | 2 +- .../devops/project/service/impl/AbsProjectServiceImpl.kt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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 d81cca4f897..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,7 +196,7 @@ class ProjectDao { ) } } - queryRemoteDevFlag?.let { + if (queryRemoteDevFlag == true) { conditions.add(JooqUtils.jsonExtractAny(PROPERTIES, "\$.remotedev").isTrue) } } 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 1d70f5eb718..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,