mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
任务,通知功能完成
This commit is contained in:
6
apps/job/api/from/job.go
Normal file
6
apps/job/api/from/job.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package from
|
||||
|
||||
type JobStatus struct {
|
||||
JobId int64 `json:"jobId"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"pandax/apps/job/api/from"
|
||||
"pandax/apps/job/entity"
|
||||
"pandax/apps/job/jobs"
|
||||
"pandax/apps/job/services"
|
||||
@@ -151,3 +152,20 @@ func (l *JobApi) StartJobForService(rc *ctx.ReqCtx) {
|
||||
}
|
||||
l.JobApp.Update(*job)
|
||||
}
|
||||
|
||||
// @Summary 修改JOB状态
|
||||
// @Description 获取JSON
|
||||
// @Tags 任务
|
||||
// @Accept application/json
|
||||
// @Product application/json
|
||||
// @Param data body from.JobStatus true "body"
|
||||
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
|
||||
// @Success 200 {string} string "{"code": 400, "message": "添加失败"}"
|
||||
// @Router /job/changeStatus [put]
|
||||
// @Security X-TOKEN
|
||||
func (l *JobApi) UpdateStatusJob(rc *ctx.ReqCtx) {
|
||||
var job from.JobStatus
|
||||
ginx.BindJsonAndValid(rc.GinCtx, &job)
|
||||
|
||||
l.JobApp.Update(entity.SysJob{JobId: job.JobId, Status: job.Status})
|
||||
}
|
||||
|
||||
@@ -114,7 +114,8 @@ func Setup() {
|
||||
}
|
||||
sysJob := entity.SysJob{}
|
||||
for i := 0; i < len(jobList); i++ {
|
||||
if jobList[i].Status != "0" && jobList[i].EntryId > 0 {
|
||||
//去除禁用的
|
||||
if jobList[i].Status != "0" {
|
||||
continue
|
||||
}
|
||||
if jobList[i].JobType == "1" {
|
||||
|
||||
@@ -48,4 +48,9 @@ func InitJobRouter(router *gin.RouterGroup) {
|
||||
job.GET("/start/:jobId", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(starteJobLog).Handle(jobApi.StartJobForService)
|
||||
})
|
||||
|
||||
updateStatusJobLog := ctx.NewLogInfo("修改状态")
|
||||
job.PUT("/changeStatus", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(updateStatusJobLog).Handle(jobApi.UpdateStatusJob)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user