message.go 3.1 KB

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