message.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package model
  2. import "time"
  3. type Message struct {
  4. ID int `gorm:"primary_key;AUTO_INCREMENT"`
  5. ServiceID int `form:"service_id" json:"service_id" gorm:"service_id"`
  6. SysName string `form:"sys_name" json:"sys_name" gorm:"sys_name"`
  7. PastureID int `form:"pasture_id" json:"pasture_id" gorm:"pasture_id"`
  8. MsgTypeID int `gorm:"column:msg_type_id"`
  9. RemindType int `gorm:"column:remind_type"`
  10. MsgContent string `gorm:"column:msg_content"`
  11. Target string `gorm:"column:target"`
  12. BodyData string `gorm:"column:body_data" json:"body_data" `
  13. CreatedAt time.Time `gorm:"column:created_at"`
  14. UpdatedAt time.Time `gorm:"column:updated_at"`
  15. Status int `gorm:"column:status"`
  16. PushCount int `gorm:"column:push_count"`
  17. PushLimit int `gorm:"column:push_limit"`
  18. ErrInfo string `gorm:"column:errInfo"`
  19. }
  20. type MessageResp struct {
  21. ID int `json:"id"`
  22. }
  23. type MessageReq struct {
  24. MsgTypeID int `json:"msg_type_id"`
  25. ServiceID int `form:"service_id" json:"service_id" gorm:"service_id"`
  26. SysName string `form:"sys_name" json:"sys_name" gorm:"sys_name"`
  27. PastureID int `form:"pasture_id" json:"pasture_id" gorm:"pasture_id"`
  28. Miniprogram Miniprogram `json:"miniprogram"`
  29. Target []string `json:"target"`
  30. Keys []string `json:"keys"`
  31. Content []Tag `json:"content"`
  32. }
  33. type MessageTypeResp struct {
  34. RowsAffected int `json:"rows_affected"`
  35. Method string `json:"method"`
  36. }
  37. type Miniprogram struct {
  38. AppID string `json:"appid"`
  39. PagePath string `json:"pagepath"`
  40. }
  41. type Tag struct {
  42. Value string `json:"value"`
  43. Color string `json:"color"`
  44. }
  45. type MessageTypeReq struct {
  46. ID int `form:"id" json:"id" gorm:"column:id; primary_key;AUTO_INCREMENT" `
  47. ServiceID int `form:"service_id" json:"service_id" gorm:"service_id"`
  48. SysName string `form:"sys_name" json:"sys_name" gorm:"sys_name"`
  49. PastureID int `form:"pasture_id" json:"pasture_id" gorm:"pasture_id"`
  50. TypeName string `form:"type_name" json:"type_name" gorm:"type_name"`
  51. RemindType int `form:"remind_type" json:"remind_type" gorm:"remind_type"`
  52. DateType int `form:"date_type" json:"date_type" gorm:"date_type"`
  53. CycleType int `form:"cycle_type" json:"cycle_type" gorm:"cycle_type"`
  54. DelayTime int `form:"delay_time" json:"delay_time" gorm:"delay_time"`
  55. PushDate int `form:"push_date" json:"push_date" gorm:"push_date"`
  56. PushTime string `form:"push_time" json:"push_time" gorm:"push_time"`
  57. IntervalTime int `form:"interval_time" json:"interval_time" gorm:"interval_time"`
  58. PushLimit int `form:"push_limit" json:"push_limit" gorm:"push_limit"`
  59. TemplateID string `form:"template_id" json:"template_id" gorm:"template_id"`
  60. Status int `form:"status" json:"status" gorm:"status"`
  61. CreatedAt time.Time `form:"created_at" json:"created_at" gorm:"created_at"`
  62. UpdatedAt time.Time `form:"updated_at" json:"updated_at" gorm:"updated_at"`
  63. }
  64. func (m MessageTypeReq) Validate() (err error) {
  65. // if m.SysName == "" || m.PastureID == 0 || m.ServiceID == 0 {
  66. // err = errors.New("sys_name or pasture_id or service_id is empty")
  67. // }
  68. return
  69. }
  70. func (p MessageReq) Validate() error {
  71. return nil
  72. }