model.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. package model
  2. import (
  3. "encoding/json"
  4. "strconv"
  5. artmdl "go-common/app/interface/openplatform/article/model"
  6. )
  7. const (
  8. // ActUpdate ...
  9. ActUpdate = "update"
  10. // ActInsert ...
  11. ActInsert = "insert"
  12. // ActDelete ...
  13. ActDelete = "delete"
  14. )
  15. // Message canal binlog message.
  16. type Message struct {
  17. Action string `json:"action"`
  18. Table string `json:"table"`
  19. New json.RawMessage `json:"new"`
  20. Old json.RawMessage `json:"old"`
  21. }
  22. // Article db struction.
  23. type Article struct {
  24. ID int64 `json:"article_id"`
  25. CTime string `json:"ctime"`
  26. CategoryID int64 `json:"category_id"`
  27. Title string `json:"title"`
  28. Summary string `json:"summary"`
  29. BannerURL string `json:"banner_url"`
  30. TemplateID int `json:"template_id"`
  31. State int `json:"state"`
  32. Mid int64 `json:"mid"`
  33. Reprint int `json:"reprint"`
  34. ImageURLs string `json:"image_urls"`
  35. OriginImageURLs string `json:"origin_image_urls"`
  36. PublishTime int `json:"publish_time"`
  37. DeletedTime int `json:"deleted_time"`
  38. Attributes int32 `json:"attributes,omitempty"`
  39. Reason string `json:"reject_reason,omitempty"`
  40. Words int64 `json:"words"`
  41. DynamicIntro string `json:"dynamic_intro"`
  42. MediaID int64 `json:"media_id"`
  43. }
  44. // SearchArticle .
  45. type SearchArticle struct {
  46. Article
  47. Tags string `json:"tags"`
  48. Content string `json:"content"`
  49. StatsView int64 `json:"stats_view"`
  50. StatsFavorite int64 `json:"stats_favorite"`
  51. StatsLikes int64 `json:"stats_likes"`
  52. StatsDisLike int64 `json:"stats_dislike"`
  53. StatsReply int64 `json:"stats_reply"`
  54. StatsShare int64 `json:"stats_share"`
  55. StatsCoin int64 `json:"stats_coin"`
  56. Keywords string `json:"keywords"`
  57. }
  58. // Author db struction.
  59. type Author struct {
  60. ID int64 `json:"id"`
  61. State int `json:"state"`
  62. Mid int64 `json:"mid"`
  63. DailyLimit int `json:"daily_limit"`
  64. }
  65. // Merge merges stat.
  66. func Merge(last, m *artmdl.StatMsg) (changed [][2]int64) {
  67. if m.View != nil && *m.View >= 0 {
  68. *last.View += *m.View
  69. changed = append(changed, [2]int64{int64(artmdl.FieldView), *last.View})
  70. }
  71. if m.Like != nil {
  72. *last.Like = *m.Like
  73. changed = append(changed, [2]int64{int64(artmdl.FieldLike), *last.Like})
  74. }
  75. if m.Dislike != nil {
  76. *last.Dislike = *m.Dislike
  77. }
  78. if m.Share != nil && *m.Share >= 0 {
  79. *last.Share += *m.Share
  80. }
  81. if m.Favorite != nil && *m.Favorite >= 0 {
  82. *last.Favorite = *m.Favorite
  83. changed = append(changed, [2]int64{int64(artmdl.FieldFav), *last.Favorite})
  84. }
  85. if m.Reply != nil && *m.Reply >= 0 {
  86. *last.Reply = *m.Reply
  87. changed = append(changed, [2]int64{int64(artmdl.FieldReply), *last.Reply})
  88. }
  89. if m.Coin != nil && *m.Coin >= 0 {
  90. *last.Coin = *m.Coin
  91. }
  92. return
  93. }
  94. // ReadURLs returns article's read urls.
  95. func ReadURLs(aid int64) []string {
  96. aidStr := strconv.FormatInt(aid, 10)
  97. return []string{
  98. "http://www.bilibili.com/read/cv/" + aidStr,
  99. "https://www.bilibili.com/read/cv/" + aidStr,
  100. "http://www.bilibili.com/read/app/" + aidStr,
  101. "https://www.bilibili.com/read/app/" + aidStr,
  102. }
  103. }
  104. // GameCacheRetry .
  105. type GameCacheRetry struct {
  106. Action string `json:"action"`
  107. Aid int64 `json:"aid"`
  108. }
  109. // FlowCacheRetry .
  110. type FlowCacheRetry struct {
  111. Aid int64 `json:"aid"`
  112. Mid int64 `json:"mid"`
  113. }
  114. // DynamicCacheRetry .
  115. type DynamicCacheRetry struct {
  116. Aid int64
  117. Mid int64
  118. Show bool
  119. Comment string
  120. Ts int64
  121. DynamicIntro string
  122. }
  123. // LikeMsg msg
  124. type LikeMsg struct {
  125. BusinessID int64 `json:"business_id"`
  126. MessageID int64 `json:"message_id"`
  127. LikesCount int64 `json:"likes_count"`
  128. DislikesCount int64 `json:"dislikes_count"`
  129. }
  130. // DynamicMsg msg
  131. type DynamicMsg struct {
  132. Card struct {
  133. Comment string `json:"comment"`
  134. Dynamic string `json:"dynamic"`
  135. OwnerID int64 `json:"owner_id"`
  136. Rid int64 `json:"rid"`
  137. Show int64 `json:"show"`
  138. Stype int64 `json:"stype"`
  139. Ts int64 `json:"ts"`
  140. Type int64 `json:"type"`
  141. } `json:"card"`
  142. }
  143. // Setting the setting struct
  144. type Setting struct {
  145. Recheck *Recheck
  146. }
  147. // Recheck setting struct
  148. type Recheck struct {
  149. Day int64 `json:"day"`
  150. View int64 `json:"view"`
  151. }
  152. // Read presents user reading duration struct
  153. type Read struct {
  154. Buvid string
  155. Aid int64
  156. Mid int64
  157. IP string
  158. From string
  159. StartTime int64
  160. EndTime int64
  161. }