mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-05-08 13:01:26 +08:00
项目目录优化,任务模块后端代码
This commit is contained in:
51
apps/job/router/job.go
Normal file
51
apps/job/router/job.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"pandax/apps/job/api"
|
||||
"pandax/apps/job/services"
|
||||
"pandax/base/ctx"
|
||||
)
|
||||
|
||||
func InitJobRouter(router *gin.RouterGroup) {
|
||||
// 登录日志
|
||||
jobApi := &api.JobApi{
|
||||
JobApp: services.JobModelDao,
|
||||
}
|
||||
job := router.Group("")
|
||||
|
||||
jobListLog := ctx.NewLogInfo("获取Job列表")
|
||||
job.GET("list", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(jobListLog).Handle(jobApi.GetJobList)
|
||||
})
|
||||
|
||||
getJobLog := ctx.NewLogInfo("获取Job信息")
|
||||
job.GET(":jobId", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(getJobLog).Handle(jobApi.GetJob)
|
||||
})
|
||||
|
||||
insertJobLog := ctx.NewLogInfo("添加Job信息")
|
||||
job.POST("", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(insertJobLog).Handle(jobApi.CreateJob)
|
||||
})
|
||||
|
||||
updateJobLog := ctx.NewLogInfo("修改Job信息")
|
||||
job.PUT("", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(updateJobLog).Handle(jobApi.UpdateJob)
|
||||
})
|
||||
|
||||
deleteJobLog := ctx.NewLogInfo("删除Job信息")
|
||||
job.DELETE(":jobId", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(deleteJobLog).Handle(jobApi.DeleteJob)
|
||||
})
|
||||
|
||||
stopJobLog := ctx.NewLogInfo("停止一个job")
|
||||
job.DELETE(":jobId", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(stopJobLog).Handle(jobApi.StopJobForService)
|
||||
})
|
||||
|
||||
starteJobLog := ctx.NewLogInfo("开启一个job")
|
||||
job.DELETE(":jobId", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(starteJobLog).Handle(jobApi.StartJobForService)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user