Skip to content

Commit

Permalink
feat: 增加降冷任务配置页面 #2564
Browse files Browse the repository at this point in the history
  • Loading branch information
lannoy0523 committed Nov 11, 2024
1 parent 5f365c4 commit b6a8647
Show file tree
Hide file tree
Showing 10 changed files with 1,288 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Page<SeparationTask>> {
val page = separationTaskService.findTasks(state, Pages.ofRequest(pageNumber, pageSize))
val page = separationTaskService.findTasks(state, projectId, repoName, Pages.ofRequest(pageNumber, pageSize))
return ResponseBuilder.success(page)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,20 @@ class SeparationTaskDao : SimpleMongoDao<TSeparationTask>() {
return exists(Query(criteria))
}

fun find(state: String?, pageRequest: PageRequest): List<TSeparationTask> {
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<TSeparationTask> {
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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ interface SeparationTaskService {
projectId: String? = null, repoName: String? = null
): Set<LocalDateTime>

fun findTasks(state: String? = null, pageRequest: PageRequest): Page<SeparationTask>
fun findTasks(
state: String? = null,
projectId: String? = null,
repoName: String? = null,
pageRequest: PageRequest
): Page<SeparationTask>

fun reInitTaskState(taskId: String)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,14 @@ class SeparationTaskServiceImpl(
return result
}

override fun findTasks(state: String?, pageRequest: PageRequest): Page<SeparationTask> {
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<SeparationTask> {
val count = separationTaskDao.count(state, projectId, repoName)
val records = separationTaskDao.find(state, projectId, repoName, pageRequest).map { it.toDto() }
return Pages.ofResponse(pageRequest, count, records)
}

Expand Down
85 changes: 85 additions & 0 deletions src/frontend/devops-op/src/api/separate.js
Original file line number Diff line number Diff line change
@@ -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
}
})
}

1 change: 1 addition & 0 deletions src/frontend/devops-op/src/icons/svg/separate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions src/frontend/devops-op/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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 }
]
Expand Down
Loading

0 comments on commit b6a8647

Please sign in to comment.