// Package job_v1 自动任务管理模块接口契约(DB 驱动的 gcron 调度 + 运行记录)。 // 规范(2026-08-27):全部 POST;URL 不含参数;入参一律 body。 package job import "github.com/gogf/gf/v2/frame/g" // ---------- 任务列表 ---------- type JobItem struct { Id uint64 `json:"id"` Name string `json:"name"` Code string `json:"code"` JobType string `json:"jobType"` CronExpr string `json:"cronExpr"` Enabled int `json:"enabled"` Remark string `json:"remark"` LastRunAt string `json:"lastRunAt"` LastResult int `json:"lastResult"` // 0未运行 1成功 2失败 LastError string `json:"lastError"` } type AutoJobListReq struct { g.Meta `path:"/auto-job/list" method:"post" tags:"Admin/AutoJob" summary:"自动任务列表"` } type AutoJobListRes struct { List []*JobItem `json:"list"` } // ---------- 保存任务(改 cron/启用/备注) ---------- type AutoJobSaveReq struct { g.Meta `path:"/auto-job/save" method:"post" tags:"Admin/AutoJob" summary:"保存自动任务(改cron/启用)"` Id uint64 `json:"id" v:"required"` CronExpr string `json:"cronExpr"` Enabled int `json:"enabled" d:"1"` Remark string `json:"remark"` } type AutoJobSaveRes struct{} // ---------- 手动触发 ---------- type AutoJobTriggerReq struct { g.Meta `path:"/auto-job/trigger" method:"post" tags:"Admin/AutoJob" summary:"手动触发任务"` Id uint64 `json:"id" v:"required"` } type AutoJobTriggerRes struct { Summary string `json:"summary"` Ok bool `json:"ok"` } // ---------- 任务运行日志 ---------- type JobLogItem struct { Id uint64 `json:"id"` JobId uint64 `json:"jobId"` JobName string `json:"jobName"` RunAt string `json:"runAt"` Result int `json:"result"` Error string `json:"error"` Summary string `json:"summary"` DurationMs int `json:"durationMs"` } type AutoJobLogListReq struct { g.Meta `path:"/auto-job/log/list" method:"post" tags:"Admin/AutoJob" summary:"任务运行日志分页"` Page int `json:"page" d:"1" v:"min:1"` Size int `json:"size" d:"10" v:"min:1|max:100"` JobId uint64 `json:"jobId"` // 0=全部 } type AutoJobLogListRes struct { List []*JobLogItem `json:"list"` Total int `json:"total"` }