From ce27ddafff28f198468bec77da7053d5c8e6b354 Mon Sep 17 00:00:00 2001 From: Leo <98382335+gaoziman@users.noreply.github.com> Date: Sat, 27 Sep 2025 14:22:35 +0800 Subject: [PATCH] =?UTF-8?q?feat(monitor):=20=E6=96=B0=E5=A2=9E=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E4=BB=BB=E5=8A=A1=E7=AE=A1=E7=90=86API=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加SysJobVo、SysJobQueryBo、SysJobForm等TypeScript类型定义 - 实现完整的定时任务CRUD API接口 - 支持分页查询、状态更新、立即执行等操作 - 提供getSysJobListPage、addSysJob、updateSysJob等核心接口 - 遵循项目API设计规范和命名约定 --- src/service/api/monitor/job/index.ts | 77 ++++++++++++++++++++ src/service/api/monitor/job/types.ts | 102 +++++++++++++++++++++++++++ 2 files changed, 179 insertions(+) create mode 100644 src/service/api/monitor/job/index.ts create mode 100644 src/service/api/monitor/job/types.ts diff --git a/src/service/api/monitor/job/index.ts b/src/service/api/monitor/job/index.ts new file mode 100644 index 0000000..2f60fba --- /dev/null +++ b/src/service/api/monitor/job/index.ts @@ -0,0 +1,77 @@ +import { request } from '@/service/http' +import type { + PageSysJobVo, + SysJobForm, + SysJobQueryBo, + SysJobSearchForm, + SysJobVo, +} from './types' + +// 重新导出类型定义 +export type { PageSysJobVo, SysJobForm, SysJobQueryBo, SysJobSearchForm, SysJobVo } + +/** + * 分页查询定时任务列表 + */ +export function getSysJobListPage(params: SysJobQueryBo) { + return request.Get>('/coder/sysJob/listPage', { params }) +} + +/** + * 查询所有定时任务 + */ +export function getSysJobList(params?: SysJobQueryBo) { + return request.Get>('/coder/sysJob/list', { params }) +} + +/** + * 根据ID查询定时任务详情 + */ +export function getSysJobById(id: string) { + return request.Get>(`/coder/sysJob/getById/${id}`) +} + +/** + * 新增定时任务 + */ +export function addSysJob(data: SysJobForm) { + return request.Post>('/coder/sysJob/add', data) +} + +/** + * 修改定时任务 + */ +export function updateSysJob(data: SysJobForm) { + return request.Post>('/coder/sysJob/update', data) +} + +/** + * 删除定时任务 + */ +export function deleteSysJobById(id: string) { + return request.Post>(`/coder/sysJob/deleteById/${id}`) +} + +/** + * 批量删除定时任务 + */ +export function batchDeleteSysJob(jobIds: string[]) { + return request.Post>('/coder/sysJob/batchDelete', jobIds) +} + +/** + * 修改任务状态 + * @param id 任务ID + * @param jobStatus 任务状态[0正常 1暂停] + * @param policyStatus 计划策略[1-立即执行 2-执行一次 3-放弃执行] + */ +export function updateSysJobStatus(id: string, jobStatus: string, policyStatus: string) { + return request.Post>(`/coder/sysJob/updateStatus/${id}/${jobStatus}/${policyStatus}`) +} + +/** + * 立即执行任务 + */ +export function runSysJobNow(id: string) { + return request.Get>(`/coder/sysJob/runNow/${id}`) +} diff --git a/src/service/api/monitor/job/types.ts b/src/service/api/monitor/job/types.ts new file mode 100644 index 0000000..4e7a396 --- /dev/null +++ b/src/service/api/monitor/job/types.ts @@ -0,0 +1,102 @@ +/** + * 定时任务管理 - 类型定义 + */ + +/** + * 定时任务实体 + */ +export interface SysJobVo { + /** 任务ID */ + jobId: string + /** 任务名称 */ + jobName: string + /** 任务类型[1-管理平台 2-小程序 3-App] */ + jobType: string + /** 类路径 */ + classPath: string + /** 方法名称 */ + methodName: string + /** cron执行表达式 */ + cronExpression: string + /** cron计划策略[1-立即执行 2-执行一次 3-放弃执行] */ + policyStatus: string + /** 任务状态[0正常 1暂停] */ + jobStatus: string + /** 任务参数 */ + jobParams?: string + /** 任务备注 */ + remark?: string + /** 创建者 */ + createBy?: string + /** 创建时间 */ + createTime?: string + /** 更新者 */ + updateBy?: string + /** 更新时间 */ + updateTime?: string +} + +/** + * 定时任务查询参数 + */ +export interface SysJobQueryBo { + /** 页码 */ + pageNo?: number + /** 页大小 */ + pageSize?: number + /** 任务名称 */ + jobName?: string + /** 任务类型 */ + jobType?: string + /** 任务状态 */ + jobStatus?: string +} + +/** + * 定时任务搜索表单 + */ +export interface SysJobSearchForm { + /** 任务名称 */ + jobName?: string + /** 任务类型 */ + jobType?: string + /** 任务状态 */ + jobStatus?: string +} + +/** + * 定时任务表单数据 + */ +export interface SysJobForm { + /** 任务ID */ + jobId?: string + /** 任务名称 */ + jobName: string + /** 任务类型[1-管理平台 2-小程序 3-App] */ + jobType: string + /** 类路径 */ + classPath: string + /** 方法名称 */ + methodName: string + /** cron执行表达式 */ + cronExpression: string + /** cron计划策略[1-立即执行 2-执行一次 3-放弃执行] */ + policyStatus: string + /** 任务状态[0正常 1暂停] */ + jobStatus: string + /** 任务参数 */ + jobParams?: string + /** 任务备注 */ + remark?: string +} + +/** + * 分页结果 + */ +export interface PageSysJobVo { + records: SysJobVo[] + total: number + size: number + current: number + pages: number +}