schedules.ts
3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import { service as http } from "@/utils/request";
import type { AxiosPromise } from "axios";
/** ---------------- 定时任务 API ---------------- **/
/**
* 创建定时任务请求参数
*/
export interface CreateSchedulePayload {
/** 标题 */
title?: string;
/** 提问内容(必需,>= 1 字符) */
question: string;
/** 开始时间(必需,格式:YYYY-MM-DDTHH:mm:ss,ISO 8601 格式) */
startTime: string;
/** 重复类型(可选,例如:DAILY) */
repeatType?: string;
/** 重复表达式(可选,例如:0) */
repeatExpr?: string;
/** 重复结束时间(可选,格式:YYYY-MM-DDTHH:mm:ss,ISO 8601 格式) */
repeatEndTime?: string;
/** 最大运行次数(可选) */
maxRuns?: number;
/** 通知类型(可选,例如:EMAIL) */
notifyType?: string;
/** 通知接收人(可选,例如:moeo3@icloud.com) */
notifyTo?: string;
/** 参数(必需,JsonNode 类型) */
params: any;
}
/**
* 创建定时任务响应
* 接口返回形式:HTTP 状态码 200,响应体为可选的 integer <int64>(任务ID)
*/
export type CreateScheduleResponse = number | undefined;
/**
* 定时任务列表
*/
export interface ScheduleItem {
id: number;
userId: number;
title: string;
question: string;
startTime: string;
recurrenceType: string;
recurrenceExpr: string;
endTime: string;
maxRuns: number;
notifyChannel: string;
notifyTo: string;
paramsJson: string;
enabled: boolean;
deleted: boolean;
runCount: number;
lastRunAt: string;
nextRunAt: string;
version: number;
createdAt: string;
updatedAt: string;
}
/**
* 获取定时任务列表响应
*/
export interface ScheduleListResponse {
total: number;
items: ScheduleItem[];
}
/**
* 创建定时任务
* POST /api/agent/deep-search-schedules
*/
export function createSchedule(
payload: CreateSchedulePayload,
): AxiosPromise<CreateScheduleResponse> {
return http.post("/agent/deep-search-schedules", payload);
}
/**
* 获取定时任务列表
* GET /api/agent/deep-search-schedules
*
* @param params 查询参数(可选)
* @returns 定时任务列表(返回包含 total 和 items 的对象)
*/
export function getScheduleList(params?: {
page?: number;
size?: number;
status?: string;
}): AxiosPromise<ScheduleListResponse> {
return http.get("/agent/deep-search-schedules", { params });
}
/**
* 暂停定时任务
* POST /api/agent/deep-search-schedules/{id}/pause
*
* @param id 定时任务ID(必需)
* @returns 响应结果
*/
export function pauseSchedule(id: number): AxiosPromise<any> {
return http.post(`/agent/deep-search-schedules/${id}/pause`);
}
/**
* 恢复定时任务
* POST /api/agent/deep-search-schedules/{id}/resume
*
* @param id 定时任务ID(必需)
* @returns 响应结果
*/
export function resumeSchedule(id: number): AxiosPromise<any> {
return http.post(`/agent/deep-search-schedules/${id}/resume`);
}
/**
* 删除定时任务
* DELETE /api/agent/deep-search-schedules/{id}
*
* @param id 定时任务ID(必需)
* @returns 响应结果
*/
export function deleteSchedule(id: number): AxiosPromise<any> {
return http.delete(`/agent/deep-search-schedules/${id}`);
}
export default {
createSchedule,
getScheduleList,
pauseSchedule,
resumeSchedule,
deleteSchedule,
};