tips.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package model
  2. import "go-common/library/time"
  3. // Tips def.
  4. type Tips struct {
  5. ID int64 `json:"id" form:"id"`
  6. Platform int8 `json:"platform" form:"platform" validate:"required,min=1,gte=1"`
  7. Version int64 `json:"version" form:"version"`
  8. Tip string `json:"tip" form:"tip" validate:"required"`
  9. Link string `json:"link" form:"link"`
  10. StartTime int64 `json:"start_time" form:"start_time" validate:"required,min=1,gte=1"`
  11. EndTime int64 `json:"end_time" form:"end_time" validate:"required,min=1,gte=1"`
  12. Level int8 `json:"level" form:"level" validate:"required,min=1,gte=1"`
  13. JudgeType int8 `json:"judge_type" form:"judge_type"`
  14. Operator string `json:"operator"`
  15. Deleted int8 `json:"deleted"`
  16. Position int8 `json:"position" form:"position" validate:"required,min=1,gte=1"`
  17. State int8 `json:"state"`
  18. Ctime time.Time `json:"ctime"`
  19. Mtime time.Time `json:"mtime"`
  20. }
  21. // TipResp def.
  22. type TipResp struct {
  23. ID int64 `json:"id"`
  24. PlatformStr string `json:"platform_str"`
  25. JudgeBuild int8 `json:"judge_build_str"`
  26. StateStr string `json:"state_str"`
  27. State int8 `json:"state"`
  28. Version int64 `json:"version"`
  29. Tip string `json:"tip"`
  30. Link string `json:"link"`
  31. Operator string `json:"operator"`
  32. Position int8 `json:"position"`
  33. Ctime int64 `json:"ctime"`
  34. Mtime int64 `json:"mtime"`
  35. }
  36. // TipState tip state
  37. func (t *Tips) TipState(stime, etime, now int64) {
  38. if stime > now {
  39. t.State = WaitShowTips
  40. } else if etime < now {
  41. t.State = ExpireTips
  42. } else {
  43. t.State = EffectiveTips
  44. }
  45. }