need.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. package need
  2. import "go-common/library/time"
  3. // type and states
  4. const (
  5. TypeCancel = 0
  6. TypeLike = 1
  7. TypeDislike = 2
  8. VerifyAccept = 2
  9. VerifyReject = 3
  10. VerifyObserved = 4
  11. NeedApply = 5
  12. NeedVerify = 6
  13. NeedReview = 7
  14. )
  15. //VerifyType is
  16. var (
  17. VerifyType = map[int]string{
  18. VerifyAccept: "采纳",
  19. VerifyReject: "驳回",
  20. VerifyObserved: "待观察",
  21. NeedApply: "申请",
  22. NeedVerify: "确认",
  23. NeedReview: "审核",
  24. }
  25. )
  26. //TableName needs
  27. func (*NInfo) TableName() string {
  28. return "needs"
  29. }
  30. //NInfo struct
  31. type NInfo struct {
  32. ID int64 `gorm:"column:id" json:"id"`
  33. Title string `gorm:"column:title" json:"title"`
  34. Content string `gorm:"column:content" json:"content"`
  35. Reporter string `gorm:"column:reporter" json:"reporter"`
  36. Status int8 `gorm:"column:status" json:"status"`
  37. LikeCounts int `gorm:"column:like_counts" json:"like_counts"`
  38. DislikeCounts int `gorm:"column:dislike_counts" json:"dislike_counts"`
  39. CTime time.Time `gorm:"column:ctime" json:"ctime"`
  40. MTime time.Time `gorm:"column:mtime" json:"mtime"`
  41. LikeState int8 `gorm:"-" json:"like_state"`
  42. }
  43. //NAddReq add request struct
  44. type NAddReq struct {
  45. Title string `form:"title" validate:"required"`
  46. Content string `form:"content" validate:"required"`
  47. }
  48. // EmpResp is empty resp.
  49. type EmpResp struct {
  50. }
  51. //NEditReq edit request struct
  52. type NEditReq struct {
  53. ID int64 `form:"id" validate:"required"`
  54. Title string `form:"title"`
  55. Content string `form:"content"`
  56. }
  57. //NListReq is list request struct
  58. type NListReq struct {
  59. Ps int `form:"ps" default:"20"`
  60. Pn int `form:"pn" default:"1"`
  61. Status int `form:"status"`
  62. Reporter string `form:"reporter"`
  63. }
  64. //NListResp is list resp struct
  65. type NListResp struct {
  66. Data []*NInfo `json:"data"`
  67. Total int64 `json:"total"`
  68. }
  69. //NVerifyReq is verify req struct
  70. type NVerifyReq struct {
  71. ID int64 `form:"id" validate:"required"`
  72. Status int `form:"status" validate:"required"`
  73. }
  74. //TableName user_likes
  75. func (*UserLikes) TableName() string {
  76. return "user_likes"
  77. }
  78. //UserLikes struct
  79. type UserLikes struct {
  80. ID int64 `gorm:"column:id" json:"id"`
  81. ReqID int64 `gorm:"column:req_id" json:"req_id"`
  82. User string `gorm:"column:user" json:"user"`
  83. LikeType int8 `gorm:"column:like_type" json:"like_type"`
  84. CTime time.Time `gorm:"column:ctime" json:"ctime"`
  85. MTime time.Time `gorm:"column:mtime" json:"mtime"`
  86. }
  87. //Likereq is userlike req struct
  88. type Likereq struct {
  89. ReqID int64 `form:"req_id" validate:"required"`
  90. LikeType int8 `form:"like_type"`
  91. }
  92. //VoteListResp is vote resp struct
  93. type VoteListResp struct {
  94. Data []*UserLikes `json:"data"`
  95. Total int64 `json:"total"`
  96. }