sys_job.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package router
  2. import (
  3. "git.cestong.com.cn/cecf/config-center-server/app/jobs/apis"
  4. models2 "git.cestong.com.cn/cecf/config-center-server/app/jobs/models"
  5. dto2 "git.cestong.com.cn/cecf/config-center-server/app/jobs/service/dto"
  6. "git.cestong.com.cn/cecf/config-center-server/common/actions"
  7. "git.cestong.com.cn/cecf/config-center-server/common/middleware"
  8. "github.com/gin-gonic/gin"
  9. jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth"
  10. )
  11. func init() {
  12. routerCheckRole = append(routerCheckRole, registerSysJobRouter)
  13. }
  14. // 需认证的路由代码
  15. func registerSysJobRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
  16. r := v1.Group("/sysjob").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
  17. {
  18. sysJob := &models2.SysJob{}
  19. r.GET("", actions.PermissionAction(), actions.IndexAction(sysJob, new(dto2.SysJobSearch), func() interface{} {
  20. list := make([]models2.SysJob, 0)
  21. return &list
  22. }))
  23. r.GET("/:id", actions.PermissionAction(), actions.ViewAction(new(dto2.SysJobById), func() interface{} {
  24. return &dto2.SysJobItem{}
  25. }))
  26. r.POST("", actions.CreateAction(new(dto2.SysJobControl)))
  27. r.PUT("", actions.PermissionAction(), actions.UpdateAction(new(dto2.SysJobControl)))
  28. r.DELETE("", actions.PermissionAction(), actions.DeleteAction(new(dto2.SysJobById)))
  29. }
  30. sysJob := apis.SysJob{}
  31. v1.GET("/job/remove/:id", sysJob.RemoveJobForService)
  32. v1.GET("/job/start/:id", sysJob.StartJobForService)
  33. }