166 lines
9.0 KiB
Go
166 lines
9.0 KiB
Go
package v1
|
||
|
||
import (
|
||
"github.com/gogf/gf/v2/os/gtime"
|
||
"github.com/gogf/gf/v2/util/gmeta"
|
||
)
|
||
|
||
// ============================== 定时任务模块 ==============================
|
||
|
||
// JobItem 任务行数据
|
||
// 用于定时任务分页列表、任务列表等场景的任务基础信息
|
||
type JobItem struct {
|
||
Id int64 `json:"id"` // 主键ID
|
||
JobName string `json:"jobName"` // 任务名称
|
||
JobAlias string `json:"jobAlias"` // 任务别名
|
||
JobGroup string `json:"jobGroup"` // 任务分组
|
||
JobTrigger string `json:"jobTrigger"` // 触发器类型
|
||
Status int `json:"status"` // 状态:0-未发布 1-运行中 2-暂停
|
||
StatusText string `json:"statusText"` // 状态文本
|
||
CronExpression string `json:"cronExpression"` // Cron表达式
|
||
ExecutePolicy int `json:"executePolicy"` // 执行策略:1-立即执行 2-执行一次 3-放弃执行
|
||
ExecutePolicyText string `json:"executePolicyText"` // 执行策略文本
|
||
IsSync int `json:"isSync"` // 是否同步:0-否 1-是
|
||
IsSyncText string `json:"isSyncText"` // 是否同步文本
|
||
Url string `json:"url"` // 任务目标:http(s)地址或本地处理方法名
|
||
Params string `json:"params"` // 请求参数(JSON)
|
||
Note string `json:"note"` // 备注
|
||
CreateUser string `json:"createUser"` // 创建人
|
||
CreateTime *gtime.Time `json:"createTime"` // 创建时间
|
||
}
|
||
|
||
// JobPageReq 定时任务分页请求
|
||
// 支持关键词、任务名称、状态等条件组合查询
|
||
type JobPageReq struct {
|
||
gmeta.Meta `method:"get" path:"/api/job/page" summary:"定时任务分页" permission:"sys:job:page" log:"定时任务-查询分页记录" logType:"query"`
|
||
PageReq // 分页基础参数
|
||
Keyword string `json:"keyword" dc:"关键词(名称/别名模糊)"` // 关键词,名称或别名模糊匹配
|
||
JobName string `json:"jobName" dc:"任务名称模糊"` // 任务名称模糊匹配
|
||
Status int `json:"status" dc:"状态:0-未发布 1-运行中 2-暂停"` // 状态
|
||
}
|
||
|
||
// JobPageRes 定时任务分页结果
|
||
type JobPageRes = PageData[JobItem]
|
||
|
||
// JobListReq 定时任务列表请求
|
||
type JobListReq struct {
|
||
gmeta.Meta `method:"get" path:"/api/job/list" summary:"定时任务列表" permission:"sys:job:list" log:"定时任务-查询列表" logType:"query"`
|
||
Keyword string `json:"keyword" dc:"关键词"` // 关键词
|
||
Status int `json:"status" dc:"状态"` // 状态
|
||
}
|
||
|
||
// JobListRes 定时任务列表结果
|
||
type JobListRes = []JobItem
|
||
|
||
// JobDetailReq 定时任务详情请求
|
||
type JobDetailReq struct {
|
||
gmeta.Meta `method:"get" path:"/api/job/detail/:id" summary:"定时任务详情" permission:"sys:job:detail" log:"定时任务-查询详情" logType:"query"`
|
||
Id int64 `json:"id" v:"required#缺少ID" dc:"任务ID"` // 任务ID
|
||
}
|
||
|
||
// JobDetailRes 定时任务详情结果
|
||
type JobDetailRes struct {
|
||
JobItem
|
||
}
|
||
|
||
// JobAddReq 新增定时任务请求
|
||
type JobAddReq struct {
|
||
gmeta.Meta `method:"post" path:"/api/job/add" summary:"新增定时任务" permission:"sys:job:add" log:"定时任务-新增记录" logType:"add"`
|
||
JobName string `json:"jobName" v:"required#请输入任务名称" dc:"任务名称"` // 任务名称
|
||
JobAlias string `json:"jobAlias" dc:"任务别名"` // 任务别名
|
||
JobGroup string `json:"jobGroup" dc:"任务分组"` // 任务分组
|
||
JobTrigger string `json:"jobTrigger" dc:"触发器类型"` // 触发器类型
|
||
CronExpression string `json:"cronExpression" v:"required#请输入Cron表达式" dc:"Cron表达式"` // Cron表达式
|
||
ExecutePolicy int `json:"executePolicy" dc:"执行策略:1-立即执行 2-执行一次 3-放弃执行"` // 执行策略
|
||
IsSync int `json:"isSync" dc:"是否同步:0-否 1-是"` // 是否同步
|
||
Url string `json:"url" v:"required#请输入任务目标" dc:"任务目标(http(s)地址或本地处理方法名)"` // 任务目标:http(s)地址或本地处理方法名
|
||
Params string `json:"params" dc:"请求参数(JSON)"` // 请求参数
|
||
Note string `json:"note" dc:"备注"` // 备注
|
||
}
|
||
|
||
// JobUpdateReq 修改定时任务请求
|
||
type JobUpdateReq struct {
|
||
gmeta.Meta `method:"put" path:"/api/job/update" summary:"修改定时任务" permission:"sys:job:update" log:"定时任务-修改记录" logType:"update"`
|
||
Id int64 `json:"id" v:"required#缺少ID" dc:"任务ID"` // 任务ID
|
||
JobName string `json:"jobName" v:"required#请输入任务名称" dc:"任务名称"` // 任务名称
|
||
JobAlias string `json:"jobAlias" dc:"任务别名"` // 任务别名
|
||
JobGroup string `json:"jobGroup" dc:"任务分组"` // 任务分组
|
||
JobTrigger string `json:"jobTrigger" dc:"触发器类型"` // 触发器类型
|
||
CronExpression string `json:"cronExpression" v:"required#请输入Cron表达式" dc:"Cron表达式"` // Cron表达式
|
||
ExecutePolicy int `json:"executePolicy" dc:"执行策略"` // 执行策略
|
||
IsSync int `json:"isSync" dc:"是否同步"` // 是否同步
|
||
Url string `json:"url" v:"required#请输入任务目标" dc:"任务目标(http(s)地址或本地处理方法名)"` // 任务目标:http(s)地址或本地处理方法名
|
||
Params string `json:"params" dc:"请求参数"` // 请求参数
|
||
Note string `json:"note" dc:"备注"` // 备注
|
||
}
|
||
|
||
// JobUpdateRes 修改定时任务结果
|
||
type JobUpdateRes struct{}
|
||
|
||
// JobDeleteReq 删除定时任务请求
|
||
type JobDeleteReq struct {
|
||
gmeta.Meta `method:"delete" path:"/api/job/delete/:id" summary:"删除定时任务" permission:"sys:job:delete" log:"定时任务-删除记录" logType:"delete"`
|
||
Id int64 `json:"id" v:"required#缺少ID" dc:"任务ID"` // 任务ID
|
||
}
|
||
|
||
// JobDeleteRes 删除定时任务结果
|
||
type JobDeleteRes struct{}
|
||
|
||
// JobBatchDeleteReq 批量删除定时任务请求
|
||
type JobBatchDeleteReq struct {
|
||
gmeta.Meta `method:"delete" path:"/api/job/batchDelete" summary:"批量删除定时任务" permission:"sys:job:batchDelete" log:"定时任务-批量删除记录" logType:"delete"`
|
||
Ids []int64 `json:"ids" v:"required#请选择要删除的记录" dc:"任务ID列表"` // 任务ID列表
|
||
}
|
||
|
||
// JobBatchDeleteRes 批量删除结果
|
||
type JobBatchDeleteRes struct{}
|
||
|
||
// JobRunOnceReq 立即执行一次任务请求
|
||
type JobRunOnceReq struct {
|
||
gmeta.Meta `method:"get" path:"/api/job/runOnce/:id" summary:"立即执行任务" permission:"sys:job:execute" log:"定时任务-执行任务" logType:"update"`
|
||
Id int64 `json:"id" v:"required#缺少ID" dc:"任务ID"` // 任务ID
|
||
}
|
||
|
||
// JobRunOnceRes 立即执行一次任务结果
|
||
type JobRunOnceRes struct{}
|
||
|
||
// JobPauseReq 暂停任务请求
|
||
type JobPauseReq struct {
|
||
gmeta.Meta `method:"get" path:"/api/job/pause/:id" summary:"暂停定时任务" permission:"sys:job:pause" log:"定时任务-暂停任务" logType:"update"`
|
||
Id int64 `json:"id" v:"required#缺少ID" dc:"任务ID"` // 任务ID
|
||
}
|
||
|
||
// JobPauseRes 暂停任务结果
|
||
type JobPauseRes struct{}
|
||
|
||
// JobResumeReq 恢复任务请求
|
||
type JobResumeReq struct {
|
||
gmeta.Meta `method:"get" path:"/api/job/resume/:id" summary:"恢复定时任务" permission:"sys:job:resume" log:"定时任务-恢复任务" logType:"update"`
|
||
Id int64 `json:"id" v:"required#缺少ID" dc:"任务ID"` // 任务ID
|
||
}
|
||
|
||
// JobResumeRes 恢复任务结果
|
||
type JobResumeRes struct{}
|
||
|
||
// JobStatusReq 设置任务状态请求
|
||
type JobStatusReq struct {
|
||
gmeta.Meta `method:"post" path:"/api/job/status" summary:"设置定时任务状态" permission:"sys:job:update" log:"定时任务-设置状态" logType:"update"`
|
||
Id int64 `json:"id" v:"required#缺少ID" dc:"任务ID"` // 任务ID
|
||
Status int `json:"status" v:"required#缺少状态" dc:"状态:0-未发布 1-运行中 2-暂停"` // 状态
|
||
}
|
||
|
||
// JobStatusRes 设置任务状态结果
|
||
type JobStatusRes struct{}
|
||
|
||
// JobDaemonStatusReq 查询调度器状态请求
|
||
type JobDaemonStatusReq struct {
|
||
gmeta.Meta `method:"get" path:"/api/job/daemonStatus" summary:"查询调度器状态" log:"定时任务-查询调度器状态" logType:"query"`
|
||
}
|
||
|
||
// JobDaemonStatusRes 调度器状态结果
|
||
type JobDaemonStatusRes struct {
|
||
Running int `json:"running"` // 运行中任务数
|
||
JobIds []string `json:"jobIds"` // 调度器中的任务键
|
||
StartTime string `json:"startTime"` // 调度器启动时间
|
||
}
|