包含多个会话的累积代码变更: - backend: AI 聊天服务、触发器调度、认证增强、WebSocket、调度器最小间隔 - admin-web: ETL 状态页、任务管理、调度配置、登录优化 - miniprogram: 看板页面、聊天集成、UI 组件、导航更新 - etl: DWS 新任务(finance_area_daily/board_cache)、连接器增强 - tenant-admin: 项目初始化 - db: 19 个迁移脚本(etl_feiqiu 11 + zqyy_app 8) - packages/shared: 枚举和工具函数更新 - tools: 数据库工具、报表生成、健康检查 - docs: PRD/架构/部署/合约文档更新 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
76 lines
2.3 KiB
TypeScript
76 lines
2.3 KiB
TypeScript
/**
|
|
* 调度任务相关 API 调用。
|
|
*/
|
|
|
|
import { apiClient } from './client';
|
|
import type { ScheduledTask, ScheduleConfig, TaskConfig, ExecutionLog, MinRunIntervalItem } from '../types';
|
|
|
|
/** 获取调度任务列表 */
|
|
export async function fetchSchedules(): Promise<ScheduledTask[]> {
|
|
const { data } = await apiClient.get<ScheduledTask[]>('/schedules');
|
|
return data;
|
|
}
|
|
|
|
/** 创建调度任务 */
|
|
export async function createSchedule(payload: {
|
|
name: string;
|
|
task_codes: string[];
|
|
task_config: TaskConfig;
|
|
schedule_config: ScheduleConfig;
|
|
run_immediately?: boolean;
|
|
min_run_interval_value?: number;
|
|
min_run_interval_unit?: string;
|
|
min_run_intervals?: Record<string, MinRunIntervalItem>;
|
|
}): Promise<ScheduledTask> {
|
|
const { data } = await apiClient.post<ScheduledTask>('/schedules', payload);
|
|
return data;
|
|
}
|
|
|
|
/** 更新调度任务 */
|
|
export async function updateSchedule(
|
|
id: string,
|
|
payload: Partial<{
|
|
name: string;
|
|
task_codes: string[];
|
|
task_config: TaskConfig;
|
|
schedule_config: ScheduleConfig;
|
|
min_run_interval_value: number;
|
|
min_run_interval_unit: string;
|
|
min_run_intervals: Record<string, MinRunIntervalItem>;
|
|
}>,
|
|
): Promise<ScheduledTask> {
|
|
const { data } = await apiClient.put<ScheduledTask>(`/schedules/${id}`, payload);
|
|
return data;
|
|
}
|
|
|
|
/** 删除调度任务 */
|
|
export async function deleteSchedule(id: string): Promise<void> {
|
|
await apiClient.delete(`/schedules/${id}`);
|
|
}
|
|
|
|
/** 启用/禁用调度任务 */
|
|
export async function toggleSchedule(id: string): Promise<ScheduledTask> {
|
|
const { data } = await apiClient.patch<ScheduledTask>(`/schedules/${id}/toggle`);
|
|
return data;
|
|
}
|
|
|
|
/** 手动执行调度任务一次(不更新调度间隔) */
|
|
export async function runScheduleNow(id: string, force = false): Promise<{ message: string; task_id: string }> {
|
|
const { data } = await apiClient.post<{ message: string; task_id: string }>(`/schedules/${id}/run`, null, {
|
|
params: force ? { force: true } : undefined,
|
|
});
|
|
return data;
|
|
}
|
|
|
|
/** 获取调度任务的执行历史 */
|
|
export async function fetchScheduleHistory(
|
|
id: string,
|
|
page = 1,
|
|
pageSize = 50,
|
|
): Promise<ExecutionLog[]> {
|
|
const { data } = await apiClient.get<ExecutionLog[]>(`/schedules/${id}/history`, {
|
|
params: { page, page_size: pageSize },
|
|
});
|
|
return data;
|
|
}
|