sys_job.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package dto
  2. import (
  3. dto2 "gas-cylinder-api/common/dto"
  4. common "gas-cylinder-api/common/model"
  5. "github.com/gin-gonic/gin"
  6. "gas-cylinder-api/app/jobs/model"
  7. "gogs.baozhida.cn/zoie/OAuth-core/api"
  8. )
  9. type SysJobSearch struct {
  10. dto2.Pagination `search:"-"`
  11. JobId int `form:"jobId" search:"type:exact;column:job_id;table:sys_job"`
  12. JobName string `form:"jobName" search:"type:icontains;column:job_name;table:sys_job"`
  13. JobGroup string `form:"jobGroup" search:"type:exact;column:job_group;table:sys_job"`
  14. CronExpression string `form:"cronExpression" search:"type:exact;column:cron_expression;table:sys_job"`
  15. InvokeTarget string `form:"invokeTarget" search:"type:exact;column:invoke_target;table:sys_job"`
  16. Status int `form:"status" search:"type:exact;column:status;table:sys_job"`
  17. }
  18. func (m *SysJobSearch) GetNeedSearch() interface{} {
  19. return *m
  20. }
  21. func (m *SysJobSearch) Bind(ctx *gin.Context) error {
  22. log := api.GetRequestLogger(ctx)
  23. err := ctx.ShouldBind(m)
  24. if err != nil {
  25. log.Errorf("Bind error: %s", err)
  26. }
  27. return err
  28. }
  29. func (m *SysJobSearch) Generate() dto2.Index {
  30. o := *m
  31. return &o
  32. }
  33. type SysJobControl struct {
  34. JobId int `json:"jobId"`
  35. JobName string `json:"jobName" validate:"required"` // 名称
  36. JobGroup string `json:"jobGroup"` // 任务分组
  37. JobType int `json:"jobType"` // 任务类型
  38. CronExpression string `json:"cronExpression"` // cron表达式
  39. InvokeTarget string `json:"invokeTarget"` // 调用目标
  40. Args string `json:"args"` // 目标参数
  41. MisfirePolicy int `json:"misfirePolicy"` // 执行策略
  42. Concurrent int `json:"concurrent"` // 是否并发
  43. Status int `json:"status"` // 状态
  44. EntryId int `json:"entryId"` // job启动时返回的id
  45. }
  46. func (s *SysJobControl) Bind(ctx *gin.Context) error {
  47. return ctx.ShouldBind(s)
  48. }
  49. func (s *SysJobControl) Generate() dto2.Control {
  50. cp := *s
  51. return &cp
  52. }
  53. func (s *SysJobControl) GenerateM() (common.ActiveRecord, error) {
  54. return &model.SysJob{
  55. JobId: s.JobId,
  56. JobName: s.JobName,
  57. JobGroup: s.JobGroup,
  58. JobType: s.JobType,
  59. CronExpression: s.CronExpression,
  60. InvokeTarget: s.InvokeTarget,
  61. Args: s.Args,
  62. MisfirePolicy: s.MisfirePolicy,
  63. Concurrent: s.Concurrent,
  64. Status: s.Status,
  65. EntryId: s.EntryId,
  66. }, nil
  67. }
  68. func (s *SysJobControl) GetId() interface{} {
  69. return s.JobId
  70. }
  71. type SysJobById struct {
  72. dto2.ObjectById
  73. }
  74. func (s *SysJobById) Generate() dto2.Control {
  75. cp := *s
  76. return &cp
  77. }
  78. func (s *SysJobById) GenerateM() (common.ActiveRecord, error) {
  79. return &model.SysJob{}, nil
  80. }
  81. type SysJobItem struct {
  82. JobId int `json:"jobId"`
  83. JobName string `json:"jobName" validate:"required"` // 名称
  84. JobGroup string `json:"jobGroup"` // 任务分组
  85. JobType int `json:"jobType"` // 任务类型
  86. CronExpression string `json:"cronExpression"` // cron表达式
  87. InvokeTarget string `json:"invokeTarget"` // 调用目标
  88. Args string `json:"args"` // 目标参数
  89. MisfirePolicy int `json:"misfirePolicy"` // 执行策略
  90. Concurrent int `json:"concurrent"` // 是否并发
  91. Status int `json:"status"` // 状态
  92. EntryId int `json:"entryId"` // job启动时返回的id
  93. }