feat: 🎨 任务立即执行

This commit is contained in:
tiansin
2021-08-21 15:55:13 +08:00
parent 9e144100c1
commit 7fe5497686
3 changed files with 37 additions and 1 deletions
+15
View File
@@ -10,6 +10,7 @@ package api
import (
"gfast/app/system/dao"
"gfast/app/system/service"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/net/ghttp"
"github.com/gogf/gf/util/gvalid"
@@ -105,6 +106,20 @@ func (c *sysJob) Stop(r *ghttp.Request) {
c.SusJsonExit(r, "定时任务管理停止成功")
}
// Run 执行任务
func (c *sysJob) Run(r *ghttp.Request) {
id := r.GetInt64("id")
job, err := service.SysJob.GetJobInfoById(id)
if err != nil {
c.FailJsonExit(r, err.Error())
}
err = service.SysJob.JobRun(job)
if err != nil {
c.FailJsonExit(r, "定时任务管理执行"+err.Error())
}
c.SusJsonExit(r, "定时任务管理执行成功")
}
// Delete 删除任务
func (c *sysJob) Delete(r *ghttp.Request) {
ids := r.GetInts("ids")