Skip to content

Commit

Permalink
Merge pull request TencentBlueKing#11303 from fcfang123/issue-11276
Browse files Browse the repository at this point in the history
pref:查询项目接口优化 TencentBlueKing#11276
  • Loading branch information
bkci-bot authored Dec 10, 2024
2 parents 2e127cb + 72f2595 commit 4722043
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ interface ServiceMonitorSpaceResource {
projectCode: String
): Result<String>

@Operation(summary = "获取监控空间业务id")
@POST
@Path("/listMonitorSpaceBizIds")
fun listMonitorSpaceBizIds(
@Parameter(description = "项目ID列表", required = false)
projectCodes: List<String>
): Result<Map<String/*projectCode*/, String/*bizId*/>>

@POST
@Path("/migrateMonitorResource")
@Operation(summary = "迁移监控空间权限资源")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ class AuthMonitorSpaceDao {
}
}

fun list(
dslContext: DSLContext,
projectCodes: List<String>
): Map<String, Long> {
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ class RbacPermissionAuthMonitorSpaceService constructor(
return "-${dbMonitorSpaceRecord.spaceBizId}"
}

override fun listMonitorSpaceBizIds(projectCode: List<String>): Map<String, String> {
return authMonitorSpaceDao.list(
dslContext = dslContext,
projectCodes = projectCode
).mapValues { "-${it.value}" }
}

private fun updateMonitorSpace(
projectCode: String,
monitorSpaceUpdateInfo: MonitorSpaceUpdateInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class SampleAuthMonitorSpaceService : AuthMonitorSpaceService {

override fun getMonitorSpaceBizId(projectCode: String): String = ""

override fun listMonitorSpaceBizIds(projectCode: List<String>): Map<String, String> {
return emptyMap()
}

override fun getMonitorSpaceDetail(spaceUid: String): MonitorSpaceDetailVO? = null

override fun getMonitorGroupConfig(groupCode: String): String? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ class ServiceMonitorSpaceResourceImpl @Autowired constructor(
return Result(monitorSpaceService.getMonitorSpaceBizId(projectCode))
}

override fun listMonitorSpaceBizIds(projectCodes: List<String>): Result<Map<String, String>> {
return Result(monitorSpaceService.listMonitorSpaceBizIds(projectCodes))
}

override fun migrateMonitorResource(
projectCodes: List<String>,
asyncMigrateOtherGroup: Boolean?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ interface AuthMonitorSpaceService {
*/
fun getMonitorSpaceBizId(projectCode: String): String

/**
* 获取监控空间业务id列表
* */
fun listMonitorSpaceBizIds(projectCode: List<String>): Map<String, String>

/**
* 获取监控空间详情
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ class ProjectDao {
)
}
}
if (queryRemoteDevFlag == true) {
conditions.add(JooqUtils.jsonExtractAny<Boolean>(PROPERTIES, "\$.remotedev").isTrue)
}
}
}
return conditions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,7 @@ abstract class AbsProjectServiceImpl @Autowired constructor(
limit: Int,
offset: Int
): List<ProjectByConditionDTO> {
logger.info("list projects by condition:$projectConditionDTO|$limit|$offset")
return projectDao.listProjectsByCondition(
dslContext = dslContext,
projectConditionDTO = projectConditionDTO,
Expand All @@ -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
)
}
}
Expand Down

0 comments on commit 4722043

Please sign in to comment.