thumbup.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. package model
  2. import (
  3. xtime "go-common/library/time"
  4. )
  5. // type and states
  6. const (
  7. StateBlank = 0
  8. StateLike = 1
  9. StateDislike = 2
  10. TypeLike = 1
  11. TypeCancelLike = 2
  12. TypeDislike = 3
  13. TypeCancelDislike = 4
  14. TypeLikeReverse = 5
  15. TypeDislikeReverse = 6
  16. ItemListLike = 1
  17. ItemListDislike = 2
  18. ItemListAll = 3
  19. UserListLike = 1
  20. UserListDislike = 2
  21. UserListAll = 3
  22. )
  23. // Business .
  24. type Business struct {
  25. ID int64 `json:"id"`
  26. Name string `json:"name"`
  27. MessageListType uint8 `json:"message_list_type"`
  28. UserListType uint8 `json:"user_list_type"`
  29. UserLikesLimit int `json:"user_likes_limit"`
  30. MessageLikesLimit int `json:"message_likes_limit"`
  31. EnableOriginID int `json:"enable_origin_id"`
  32. }
  33. // EnableItemLikeList .
  34. func (b *Business) EnableItemLikeList() bool {
  35. return (b.MessageListType == ItemListLike) || (b.MessageListType == ItemListAll)
  36. }
  37. // EnableItemDislikeList .
  38. func (b *Business) EnableItemDislikeList() bool {
  39. return (b.MessageListType == ItemListDislike) || (b.MessageListType == ItemListAll)
  40. }
  41. // EnableUserLikeList .
  42. func (b *Business) EnableUserLikeList() bool {
  43. return (b.UserListType == UserListLike) || (b.UserListType == UserListAll)
  44. }
  45. // EnableUserDislikeList .
  46. func (b *Business) EnableUserDislikeList() bool {
  47. return (b.UserListType == UserListDislike) || (b.UserListType == UserListAll)
  48. }
  49. // UserLikeRecord .
  50. type UserLikeRecord struct {
  51. Mid int64 `json:"mid"`
  52. Time xtime.Time `json:"time"`
  53. }
  54. // LikeItem .
  55. type LikeItem struct {
  56. Business string
  57. OriginID int64
  58. MessageID int64
  59. }
  60. // LikeCounts .
  61. type LikeCounts struct {
  62. Like int64
  63. Dislike int64
  64. UpMid int64
  65. }
  66. // Stats .
  67. type Stats struct {
  68. OriginID int64 `json:"origin_id"`
  69. ID int64 `json:"id"`
  70. Likes int64 `json:"likes"`
  71. Dislikes int64 `json:"dislikes"`
  72. }
  73. // ItemLikeRecord .
  74. type ItemLikeRecord struct {
  75. MessageID int64 `json:"message_id"`
  76. Time xtime.Time `json:"time"`
  77. }
  78. // StatMsg .
  79. type StatMsg struct {
  80. Type string `json:"type"`
  81. ID int64 `json:"id"`
  82. Count int64 `json:"count"`
  83. Timestamp int64 `json:"timestamp"`
  84. OriginID int64 `json:"origin_id,omitempty"`
  85. DislikeCount int64 `json:"dislike_count,omitempty"`
  86. Mid int64 `json:"mid,omitempty"`
  87. UpMid int64 `json:"up_mid,omitempty"`
  88. }