feat(调度任务): 实现调度任务管理功能

新增调度任务模块,支持任务的增删改查、启停及手动执行
- 后端添加 schedule_job 模型、服务、路由及调度器工具类
- 前端新增调度任务管理页面
- 修改 flow 相关接口将 id 类型从 String 改为 i64
- 添加 tokio-cron-scheduler 依赖实现定时任务调度
- 初始化时加载已启用任务并注册到调度器
This commit is contained in:
2025-09-24 00:21:30 +08:00
parent cadd336dee
commit 8c06849254
29 changed files with 1253 additions and 103 deletions

View File

@ -4,7 +4,7 @@ use sea_orm::entity::prelude::*;
#[sea_orm(table_name = "flows")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: String,
pub id: i64,
pub name: Option<String>,
pub yaml: Option<String>,
pub design_json: Option<String>,

View File

@ -5,7 +5,7 @@ use sea_orm::entity::prelude::*;
pub struct Model {
#[sea_orm(primary_key)]
pub id: i64,
pub flow_id: String,
pub flow_id: i64,
// 新增:流程编码(可空)
pub flow_code: Option<String>,
pub input: Option<String>,

View File

@ -11,4 +11,5 @@ pub mod request_log;
pub mod position;
pub mod user_position;
pub mod flow;
pub mod flow_run_log;
pub mod flow_run_log;
pub mod schedule_job;

View File

@ -0,0 +1,19 @@
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, serde::Serialize, serde::Deserialize)]
#[sea_orm(table_name = "schedule_jobs")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: String,
pub name: String,
pub cron_expr: String,
pub enabled: bool,
pub flow_code: String,
pub created_at: DateTimeWithTimeZone,
pub updated_at: DateTimeWithTimeZone,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {}