sysjob.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. package dto
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "device-manage/app/admin/models"
  5. "device-manage/common/dto"
  6. "device-manage/common/log"
  7. common "device-manage/common/models"
  8. )
  9. type SysJobSearch struct {
  10. dto.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. err := ctx.ShouldBind(m)
  23. if err != nil {
  24. log.Errorf("MsgID[%s] Bind error: %s", err)
  25. }
  26. return err
  27. }
  28. func (m *SysJobSearch) Generate() dto.Index {
  29. o := *m
  30. return &o
  31. }
  32. type SysJobControl struct {
  33. JobId uint `json:"jobId"`
  34. JobName string `json:"jobName" validate:"required"` // 名称
  35. JobGroup string `json:"jobGroup"` // 任务分组
  36. JobType int `json:"jobType"` // 任务类型
  37. CronExpression string `json:"cronExpression"` // cron表达式
  38. InvokeTarget string `json:"invokeTarget"` // 调用目标
  39. Args string `json:"args"` // 目标参数
  40. MisfirePolicy int `json:"misfirePolicy"` // 执行策略
  41. Concurrent int `json:"concurrent"` // 是否并发
  42. Status int `json:"status"` // 状态
  43. EntryId int `json:"entryId"` // job启动时返回的id
  44. }
  45. func (s *SysJobControl) Bind(ctx *gin.Context) error {
  46. return ctx.ShouldBind(s)
  47. }
  48. func (s *SysJobControl) Generate() dto.Control {
  49. cp := *s
  50. return &cp
  51. }
  52. func (s *SysJobControl) GenerateM() (common.ActiveRecord, error) {
  53. return &models.SysJob{
  54. JobId: s.JobId,
  55. JobName: s.JobName,
  56. JobGroup: s.JobGroup,
  57. JobType: s.JobType,
  58. CronExpression: s.CronExpression,
  59. InvokeTarget: s.InvokeTarget,
  60. Args: s.Args,
  61. MisfirePolicy: s.MisfirePolicy,
  62. Concurrent: s.Concurrent,
  63. Status: s.Status,
  64. EntryId: s.EntryId,
  65. }, nil
  66. }
  67. func (s *SysJobControl) GetId() interface{} {
  68. return s.JobId
  69. }
  70. type SysJobById struct {
  71. dto.ObjectById
  72. }
  73. func (s *SysJobById) Generate() dto.Control {
  74. cp := *s
  75. return &cp
  76. }
  77. func (s *SysJobById) GenerateM() (common.ActiveRecord, error) {
  78. return &models.SysJob{}, nil
  79. }
  80. type SysJobItem struct {
  81. JobId uint `json:"jobId"`
  82. JobName string `json:"jobName" validate:"required"` // 名称
  83. JobGroup string `json:"jobGroup"` // 任务分组
  84. JobType int `json:"jobType"` // 任务类型
  85. CronExpression string `json:"cronExpression"` // cron表达式
  86. InvokeTarget string `json:"invokeTarget"` // 调用目标
  87. Args string `json:"args"` // 目标参数
  88. MisfirePolicy int `json:"misfirePolicy"` // 执行策略
  89. Concurrent int `json:"concurrent"` // 是否并发
  90. Status int `json:"status"` // 状态
  91. EntryId int `json:"entryId"` // job启动时返回的id
  92. }