thumbup.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. package model
  2. import (
  3. xtime "go-common/library/time"
  4. "time"
  5. )
  6. // type and states
  7. const (
  8. TypeLike = 1
  9. TypeCancelLike = 2
  10. TypeDislike = 3
  11. TypeCancelDislike = 4
  12. // only used by internal
  13. TypeLikeReverse = 5
  14. TypeDislikeReverse = 6
  15. StateBlank = 0
  16. StateLike = 1
  17. StateDislike = 2
  18. ItemListLike = 1
  19. ItemListDislike = 2
  20. ItemListAll = 3
  21. UserListLike = 1
  22. UserListDislike = 2
  23. UserListAll = 3
  24. )
  25. // Business .
  26. type Business struct {
  27. ID int64 `json:"id"`
  28. Name string `json:"name"`
  29. MessageListType uint8 `json:"message_list_type"`
  30. UserListType uint8 `json:"user_list_type"`
  31. UserLikesLimit int `json:"user_likes_limit"`
  32. MessageLikesLimit int `json:"message_likes_limit"`
  33. EnableOriginID int `json:"enable_origin_id"`
  34. }
  35. // EnableItemLikeList .
  36. func (b *Business) EnableItemLikeList() bool {
  37. return (b.MessageListType == ItemListLike) || (b.MessageListType == ItemListAll)
  38. }
  39. // EnableItemDislikeList .
  40. func (b *Business) EnableItemDislikeList() bool {
  41. return (b.MessageListType == ItemListDislike) || (b.MessageListType == ItemListAll)
  42. }
  43. // EnableUserLikeList .
  44. func (b *Business) EnableUserLikeList() bool {
  45. return (b.UserListType == UserListLike) || (b.UserListType == UserListAll)
  46. }
  47. // EnableUserDislikeList .
  48. func (b *Business) EnableUserDislikeList() bool {
  49. return (b.UserListType == UserListDislike) || (b.UserListType == UserListAll)
  50. }
  51. // Stats .
  52. type Stats struct {
  53. OriginID int64 `json:"origin_id"`
  54. ID int64 `json:"id"`
  55. Likes int64 `json:"likes"`
  56. Dislikes int64 `json:"dislikes"`
  57. }
  58. // RawStats .
  59. type RawStats struct {
  60. Stats
  61. LikesChange int64 `json:"likes_change"`
  62. DislikesChange int64 `json:"dislikes_change"`
  63. }
  64. // StatsWithLike .
  65. type StatsWithLike struct {
  66. Stats
  67. LikeState int8 `json:"like_state"`
  68. }
  69. // UserLikeRecord .
  70. type UserLikeRecord struct {
  71. Mid int64 `json:"mid"`
  72. Time xtime.Time `json:"time"`
  73. }
  74. // ItemLikeRecord .
  75. type ItemLikeRecord struct {
  76. MessageID int64 `json:"message_id"`
  77. Time xtime.Time `json:"time"`
  78. }
  79. // UserTotalLike .
  80. type UserTotalLike struct {
  81. Total int `json:"total"`
  82. List []*ItemLikeRecord `json:"list"`
  83. }
  84. // MultiBusinessItem .
  85. type MultiBusinessItem struct {
  86. OriginID int64 `json:"origin_id"`
  87. MessageID int64 `json:"message_id"`
  88. }
  89. // MultiBusiness .
  90. type MultiBusiness struct {
  91. Mid int64 `json:"mid"`
  92. Businesses map[string][]*MultiBusinessItem `json:"businesses" validate:"required"`
  93. }
  94. // StatMsg databus stat message
  95. type StatMsg struct {
  96. Type string `json:"type"`
  97. ID int64 `json:"id"`
  98. Count int64 `json:"count"`
  99. Timestamp int64 `json:"timestamp"`
  100. OriginID int64 `json:"origin_id,omitempty"`
  101. DislikeCount int64 `json:"dislike_count,omitempty"`
  102. Mid int64 `json:"mid,omitempty"`
  103. UpMid int64 `json:"up_mid,omitempty"`
  104. }
  105. // LikeMsg like message
  106. type LikeMsg struct {
  107. Type int8
  108. Mid int64
  109. UpMid int64
  110. LikeTime time.Time
  111. Business string
  112. OriginID int64
  113. MessageID int64
  114. }
  115. // ItemMsg .
  116. type ItemMsg struct {
  117. State int8 `json:"state"`
  118. Business string `json:"business"`
  119. OriginID int64 `json:"origin_id"`
  120. MessageID int64 `json:"message_id"`
  121. }
  122. // UserMsg .
  123. type UserMsg struct {
  124. Mid int64 `json:"mid"`
  125. State int8 `json:"state"`
  126. Business string `json:"business"`
  127. }
  128. // LikeItem like item
  129. type LikeItem struct {
  130. BusinessID int64
  131. OriginID int64
  132. MessageID int64
  133. }
  134. // LikeCounts like counts
  135. type LikeCounts struct {
  136. Like int64
  137. Dislike int64
  138. UpMid int64 `json:"-"`
  139. }
  140. // UpMidsReq .
  141. type UpMidsReq struct {
  142. OriginID int64 `json:"origin_id" validate:"min=0"`
  143. MessageID int64 `json:"message_id" validate:"min=1,required"`
  144. UpMid int64 `json:"up_mid" validate:"required"`
  145. }