| 1234567891011121314151617181920212223242526272829303132333435363738 |
- // api/schedule.ts:定时任务(增删改查 / 启停 / 立即执行 / 执行记录)。
- import { defHttp } from '/@/utils/http/axios/index';
- enum Api {
- schedules = '/ventAI/api/schedules',
- }
- /**
- * 定时任务接口
- */
- export const createSchedule = (data: {
- name: string;
- schedule?: { freq: string; hour?: number; minute?: number; day_of_week?: number; day_of_month?: number };
- cron_expr?: string;
- prompt: string;
- notify_webhook?: string;
- }) => defHttp.post({ url: Api.schedules, data }, { isTransformResponse: false });
- export const getScheduleList = (include_disabled = true) =>
- defHttp.get({ url: Api.schedules, params: { include_disabled } }, { joinParamsToUrl: true, isTransformResponse: false });
- export const getScheduleDetail = (task_id: number) => defHttp.get({ url: `${Api.schedules}/${task_id}` }, { isTransformResponse: false });
- export const updateSchedule = (
- task_id: number,
- data: { name?: string; schedule?: Record<string, any>; cron_expr?: string; prompt?: string; notify_webhook?: string }
- ) => defHttp.put({ url: `${Api.schedules}/${task_id}`, data }, { isTransformResponse: false });
- export const pauseSchedule = (task_id: number) => defHttp.post({ url: `${Api.schedules}/${task_id}/pause` }, { isTransformResponse: false });
- export const resumeSchedule = (task_id: number) => defHttp.post({ url: `${Api.schedules}/${task_id}/resume` }, { isTransformResponse: false });
- export const deleteSchedule = (id: number) => defHttp.delete({ url: `${Api.schedules}/${id}` }, { isTransformResponse: false });
- export const getScheduleRuns = (task_id: number, limit = 50) =>
- defHttp.get({ url: `${Api.schedules}/${task_id}/runs`, params: { limit } }, { joinParamsToUrl: true, isTransformResponse: false });
- export const runScheduleNow = (task_id: number) => defHttp.post({ url: `${Api.schedules}/${task_id}/run` }, { isTransformResponse: false });
|