任务,通知功能完成

This commit is contained in:
PandaGoAdmin
2021-12-26 22:24:44 +08:00
parent 816791f148
commit e85bbbc030
17 changed files with 48 additions and 40 deletions

6
apps/job/api/from/job.go Normal file
View File

@@ -0,0 +1,6 @@
package from
type JobStatus struct {
JobId int64 `json:"jobId"`
Status string `json:"status"`
}

View File

@@ -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})
}

View File

@@ -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" {

View File

@@ -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)
})
}