From b6a864760b5979069aa0936d34d61a846a84fc4a Mon Sep 17 00:00:00 2001 From: lannoy0523 <935275025@qq.com> Date: Wed, 6 Nov 2024 16:53:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E9=99=8D=E5=86=B7?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E9=85=8D=E7=BD=AE=E9=A1=B5=E9=9D=A2=20#2564?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/UserSeparationController.kt | 4 +- .../job/separation/dao/SeparationTaskDao.kt | 16 +- .../service/SeparationTaskService.kt | 7 +- .../service/impl/SeparationTaskServiceImpl.kt | 11 +- src/frontend/devops-op/src/api/separate.js | 85 ++++ .../devops-op/src/icons/svg/separate.svg | 1 + src/frontend/devops-op/src/router/index.js | 22 + .../src/views/separation/ShowData.vue | 419 ++++++++++++++++++ .../CreateOrUpdateSeparationTaskDialog.vue | 386 ++++++++++++++++ .../devops-op/src/views/separation/index.vue | 348 +++++++++++++++ 10 files changed, 1288 insertions(+), 11 deletions(-) create mode 100644 src/frontend/devops-op/src/api/separate.js create mode 100644 src/frontend/devops-op/src/icons/svg/separate.svg create mode 100644 src/frontend/devops-op/src/views/separation/ShowData.vue create mode 100644 src/frontend/devops-op/src/views/separation/components/CreateOrUpdateSeparationTaskDialog.vue create mode 100644 src/frontend/devops-op/src/views/separation/index.vue diff --git a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/controller/user/UserSeparationController.kt b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/controller/user/UserSeparationController.kt index 4355ae3cca..e0611f78c8 100644 --- a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/controller/user/UserSeparationController.kt +++ b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/controller/user/UserSeparationController.kt @@ -75,10 +75,12 @@ class UserSeparationController( @GetMapping("/tasks") fun tasks( @RequestParam(required = false) state: String? = null, + @RequestParam(required = false) projectId: String? = null, + @RequestParam(required = false) repoName: String? = null, @RequestParam(required = false, defaultValue = "$DEFAULT_PAGE_NUMBER") pageNumber: Int = DEFAULT_PAGE_NUMBER, @RequestParam(required = false, defaultValue = "$DEFAULT_PAGE_SIZE") pageSize: Int = DEFAULT_PAGE_SIZE, ): Response> { - val page = separationTaskService.findTasks(state, Pages.ofRequest(pageNumber, pageSize)) + val page = separationTaskService.findTasks(state, projectId, repoName, Pages.ofRequest(pageNumber, pageSize)) return ResponseBuilder.success(page) } diff --git a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/separation/dao/SeparationTaskDao.kt b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/separation/dao/SeparationTaskDao.kt index b9ae3c0b5a..36d66c16dc 100644 --- a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/separation/dao/SeparationTaskDao.kt +++ b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/separation/dao/SeparationTaskDao.kt @@ -102,16 +102,20 @@ class SeparationTaskDao : SimpleMongoDao() { return exists(Query(criteria)) } - fun find(state: String?, pageRequest: PageRequest): List { - val criteria = Criteria() - state?.let { criteria.and(TSeparationTask::state.name).isEqualTo(it) } - return find(Query(criteria).with(pageRequest)) + fun find(state: String?, projectId: String?, repoName: String?, pageRequest: PageRequest): List { + return find(buildQuery(state, projectId, repoName).with(pageRequest)) + } + + fun count(state: String?, projectId: String?, repoName: String?): Long { + return count(buildQuery(state, projectId, repoName)) } - fun count(state: String?): Long { + private fun buildQuery(state: String?, projectId: String?, repoName: String?): Query { val criteria = Criteria() state?.let { criteria.and(TSeparationTask::state.name).isEqualTo(it) } - return count(Query(criteria)) + projectId?.let { criteria.and(TSeparationTask::projectId.name).isEqualTo(projectId) } + repoName?.let { criteria.and(TSeparationTask::repoName.name).isEqualTo(repoName) } + return Query(criteria) } fun updateState( diff --git a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/separation/service/SeparationTaskService.kt b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/separation/service/SeparationTaskService.kt index c64378d4c6..e4c38039bf 100644 --- a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/separation/service/SeparationTaskService.kt +++ b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/separation/service/SeparationTaskService.kt @@ -41,7 +41,12 @@ interface SeparationTaskService { projectId: String? = null, repoName: String? = null ): Set - fun findTasks(state: String? = null, pageRequest: PageRequest): Page + fun findTasks( + state: String? = null, + projectId: String? = null, + repoName: String? = null, + pageRequest: PageRequest + ): Page fun reInitTaskState(taskId: String) diff --git a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/separation/service/impl/SeparationTaskServiceImpl.kt b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/separation/service/impl/SeparationTaskServiceImpl.kt index 1a2cb4cf93..371093084c 100644 --- a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/separation/service/impl/SeparationTaskServiceImpl.kt +++ b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/separation/service/impl/SeparationTaskServiceImpl.kt @@ -107,9 +107,14 @@ class SeparationTaskServiceImpl( return result } - override fun findTasks(state: String?, pageRequest: PageRequest): Page { - val count = separationTaskDao.count(state) - val records = separationTaskDao.find(state, pageRequest).map { it.toDto() } + override fun findTasks( + state: String?, + projectId: String?, + repoName: String?, + pageRequest: PageRequest + ): Page { + val count = separationTaskDao.count(state, projectId, repoName) + val records = separationTaskDao.find(state, projectId, repoName, pageRequest).map { it.toDto() } return Pages.ofResponse(pageRequest, count, records) } diff --git a/src/frontend/devops-op/src/api/separate.js b/src/frontend/devops-op/src/api/separate.js new file mode 100644 index 0000000000..b07f0c4de1 --- /dev/null +++ b/src/frontend/devops-op/src/api/separate.js @@ -0,0 +1,85 @@ +import request from '@/utils/request' + +const PREFIX_SERVICES = '/job/api/job/separation' + +export function querySeparateTask(data) { + return request({ + url: `${PREFIX_SERVICES}/tasks`, + method: 'get', + params: data + }) +} + +export function createSeparateTask(data) { + return request({ + url: `${PREFIX_SERVICES}/`, + method: 'post', + data: data + }) +} + +export function updateSeparateTask(taskId) { + return request({ + url: `${PREFIX_SERVICES}/update/${taskId}/state`, + method: 'post' + }) +} + +// 查询冷表中节点信息 +export function queryColdNodeData(body) { + return request({ + url: `${PREFIX_SERVICES}/node/${body.projectId}/${body.repoName}`, + method: 'get', + params: { + fullPath: body.fullPath + } + }) +} + +// 查询冷表中版本信息 +export function queryColdVersionData(body) { + return request({ + url: `${PREFIX_SERVICES}/version/${body.projectId}/${body.repoName}`, + method: 'get', + params: { + packageKey: body.packageKey, + version: body.version + } + }) +} + +// 分页查询包 +export function queryPackageData(body) { + return request({ + url: `${PREFIX_SERVICES}/package/page/${body.projectId}/${body.repoName}`, + method: 'get', + params: body.packageOption + }) +} + +// 分页查询版本 +export function queryVersionData(body) { + return request({ + url: `${PREFIX_SERVICES}/version/page/${body.projectId}/${body.repoName}`, + method: 'get', + params: { + packageKey: body.packageKey, + separationDate: body.separationDate, + option: body.versionOption + } + }) +} + +// 分页查询节点 +export function queryNodeData(body) { + return request({ + url: `${PREFIX_SERVICES}/node/page/${body.projectId}/${body.repoName}`, + method: 'get', + params: { + fullPath: body.fullPath, + separationDate: body.separationDate, + option: body.nodeOption + } + }) +} + diff --git a/src/frontend/devops-op/src/icons/svg/separate.svg b/src/frontend/devops-op/src/icons/svg/separate.svg new file mode 100644 index 0000000000..3a63e0663c --- /dev/null +++ b/src/frontend/devops-op/src/icons/svg/separate.svg @@ -0,0 +1 @@ + diff --git a/src/frontend/devops-op/src/router/index.js b/src/frontend/devops-op/src/router/index.js index e5e859f09c..f5b1cd081f 100644 --- a/src/frontend/devops-op/src/router/index.js +++ b/src/frontend/devops-op/src/router/index.js @@ -26,6 +26,8 @@ export const ROUTER_NAME_FILE_SYSTEM_RECORD = 'FileSystemRecord' export const ROUTER_NAME_REPO_CONFIG = 'RepoConfig' export const ROUTER_NAME_RATE_LIMITER_CONFIG = 'RateLimiterConfig' export const ROUTER_NAME_PRELOAD_CONFIG = 'PreloadConfig' +export const ROUTER_NAME_SEPARATION_CONFIG = 'SeparationConfig' +export const ROUTER_NAME_SEPARATION_RECORD = 'SeparationRecord' Vue.use(Router) @@ -339,6 +341,26 @@ export const asyncRoutes = [ } ] }, + { + path: '/separation-config', + component: Layout, + meta: { title: '降冷任务配置', icon: 'separate' }, + redirect: '/separation-config/task', + children: [ + { + path: 'task', + name: ROUTER_NAME_SEPARATION_CONFIG, + meta: { title: '降冷任务', icon: 'separate' }, + component: () => import('@/views/separation/index') + }, + { + path: 'infos', + name: ROUTER_NAME_SEPARATION_RECORD, + meta: { title: '数据查询', icon: 'separate' }, + component: () => import('@/views/separation/ShowData') + } + ] + }, // 404 page must be placed at the end !!! { path: '*', redirect: '/404', hidden: true } ] diff --git a/src/frontend/devops-op/src/views/separation/ShowData.vue b/src/frontend/devops-op/src/views/separation/ShowData.vue new file mode 100644 index 0000000000..8dc5d4207e --- /dev/null +++ b/src/frontend/devops-op/src/views/separation/ShowData.vue @@ -0,0 +1,419 @@ + + + + + + diff --git a/src/frontend/devops-op/src/views/separation/components/CreateOrUpdateSeparationTaskDialog.vue b/src/frontend/devops-op/src/views/separation/components/CreateOrUpdateSeparationTaskDialog.vue new file mode 100644 index 0000000000..21f998efbe --- /dev/null +++ b/src/frontend/devops-op/src/views/separation/components/CreateOrUpdateSeparationTaskDialog.vue @@ -0,0 +1,386 @@ + + + + diff --git a/src/frontend/devops-op/src/views/separation/index.vue b/src/frontend/devops-op/src/views/separation/index.vue new file mode 100644 index 0000000000..e47f97b913 --- /dev/null +++ b/src/frontend/devops-op/src/views/separation/index.vue @@ -0,0 +1,348 @@ + + + + + +