dynamic.go 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. package model
  2. import (
  3. "encoding/json"
  4. "strconv"
  5. v1 "go-common/app/service/main/archive/api"
  6. )
  7. // DyCard dynamic data.
  8. type DyCard struct {
  9. Card json.RawMessage `json:"card"`
  10. Desc struct {
  11. UID int64 `json:"uid"`
  12. Type int `json:"type"`
  13. ACL int `json:"acl"`
  14. Rid int64 `json:"rid"`
  15. View int32 `json:"view"`
  16. Repost int32 `json:"repost"`
  17. Comment int32 `json:"comment"`
  18. Like int32 `json:"like"`
  19. IsLiked int32 `json:"is_liked"`
  20. DynamicID int64 `json:"dynamic_id"`
  21. CommentID int64 `json:"comment_id"`
  22. Timestamp int64 `json:"timestamp"`
  23. PreDyID int64 `json:"pre_dy_id"`
  24. OrigDyID int64 `json:"orig_dy_id"`
  25. OrigType int `json:"orig_type"`
  26. RType int `json:"r_type"`
  27. InnerID int64 `json:"inner_id"`
  28. UserProfile *UserProfile `json:"user_profile,omitempty"`
  29. } `json:"desc"`
  30. Extension *DyExtension `json:"extension,omitempty"`
  31. }
  32. // DyResult dynamic result
  33. type DyResult struct {
  34. Card json.RawMessage `json:"card"`
  35. Desc struct {
  36. UID int64 `json:"uid"`
  37. Type int `json:"type"`
  38. ACL int `json:"acl"`
  39. Rid int64 `json:"rid"`
  40. View int32 `json:"view"`
  41. Repost int32 `json:"repost"`
  42. Comment int32 `json:"comment"`
  43. Like int32 `json:"like"`
  44. IsLiked int32 `json:"is_liked"`
  45. DynamicID string `json:"dynamic_id"`
  46. CommentID int64 `json:"comment_id"`
  47. Timestamp int64 `json:"timestamp"`
  48. PreDyID string `json:"pre_dy_id"`
  49. OrigDyID string `json:"orig_dy_id"`
  50. OrigType int `json:"orig_type"`
  51. RType int `json:"r_type"`
  52. InnerID int64 `json:"inner_id"`
  53. UserProfile *UserProfile `json:"user_profile,omitempty"`
  54. } `json:"desc"`
  55. Extension *DyExtension `json:"extension,omitempty"`
  56. }
  57. // DyExtension .
  58. type DyExtension struct {
  59. VoteCfg *struct {
  60. VoteID int64 `json:"vote_id"`
  61. Desc string `json:"desc"`
  62. JoinNum int64 `json:"join_num"`
  63. } `json:"vote_cfg,omitempty"`
  64. }
  65. // DyTotal out dynamic total.
  66. type DyTotal struct {
  67. HasMore bool `json:"has_more"`
  68. List []*DyItem `json:"list"`
  69. }
  70. // DyItem out dynamic item.
  71. type DyItem struct {
  72. Type int `json:"type"`
  73. Top bool `json:"top"`
  74. Card *DyResult `json:"card,omitempty"`
  75. Archive *VideoItem `json:"video,omitempty"`
  76. Fold []*DyItem `json:"fold,omitempty"`
  77. Ctime int64 `json:"ctime"`
  78. Privacy bool `json:"privacy"`
  79. }
  80. // UserProfile dynamic item user profile.
  81. type UserProfile struct {
  82. Pendant struct {
  83. Pid int64 `json:"pid"`
  84. Name string `json:"name"`
  85. Image string `json:"image"`
  86. Expire int64 `json:"expire"`
  87. } `json:"pendant,omitempty"`
  88. DecorateCard struct {
  89. Mid int64 `json:"mid"`
  90. ID int64 `json:"id"`
  91. CardURL string `json:"card_url"`
  92. CardType int `json:"card_type"`
  93. Name string `json:"name"`
  94. ExpireTime int64 `json:"expire_time"`
  95. CardTypeName string `json:"card_type_name"`
  96. UID int64 `json:"uid"`
  97. } `json:"decorate_card,omitempty"`
  98. }
  99. // FromCard format dynamic card.
  100. func (d *DyResult) FromCard(c *DyCard) {
  101. d.Card = c.Card
  102. d.Desc.UID = c.Desc.UID
  103. d.Desc.Type = c.Desc.Type
  104. d.Desc.ACL = c.Desc.ACL
  105. d.Desc.Rid = c.Desc.Rid
  106. d.Desc.View = c.Desc.View
  107. d.Desc.Repost = c.Desc.Repost
  108. d.Desc.Comment = c.Desc.Comment
  109. d.Desc.Like = c.Desc.Like
  110. d.Desc.IsLiked = c.Desc.IsLiked
  111. d.Desc.DynamicID = strconv.FormatInt(c.Desc.DynamicID, 10)
  112. d.Desc.CommentID = c.Desc.CommentID
  113. d.Desc.Timestamp = c.Desc.Timestamp
  114. d.Desc.PreDyID = strconv.FormatInt(c.Desc.PreDyID, 10)
  115. d.Desc.OrigDyID = strconv.FormatInt(c.Desc.OrigDyID, 10)
  116. d.Desc.OrigType = c.Desc.OrigType
  117. d.Desc.RType = c.Desc.RType
  118. d.Desc.InnerID = c.Desc.InnerID
  119. if c.Extension != nil && c.Extension.VoteCfg != nil {
  120. d.Extension = c.Extension
  121. }
  122. if c.Desc.UserProfile != nil {
  123. d.Desc.UserProfile = c.Desc.UserProfile
  124. }
  125. }
  126. // DyList dynamic list.
  127. type DyList struct {
  128. HasMore int `json:"has_more"`
  129. Cards []*DyCard `json:"cards"`
  130. }
  131. // DyActItem dynamic other action items.
  132. type DyActItem struct {
  133. Aid int64 `json:"aid"`
  134. Type int `json:"type"`
  135. ActionTime int64 `json:"action_time"`
  136. Privacy bool `json:"privacy"`
  137. }
  138. // VideoItem user action video item.
  139. type VideoItem struct {
  140. Aid int64 `json:"aid"`
  141. Pic string `json:"pic"`
  142. Title string `json:"title"`
  143. Duration int64 `json:"duration"`
  144. Author struct {
  145. Mid int64 `json:"mid"`
  146. Name string `json:"name"`
  147. Face string `json:"face"`
  148. }
  149. Stat struct {
  150. View int32 `json:"view"`
  151. Danmaku int32 `json:"danmaku"`
  152. Reply int32 `json:"reply"`
  153. Fav int32 `json:"favorite"`
  154. Coin int32 `json:"coin"`
  155. Share int32 `json:"share"`
  156. Like int32 `json:"like"`
  157. }
  158. Rights v1.Rights `json:"rights"`
  159. ActionTime int64 `json:"action_time"`
  160. }
  161. // DyListArg .
  162. type DyListArg struct {
  163. Mid int64 `form:"-"`
  164. Vmid int64 `form:"mid" validate:"min=1"`
  165. DyID int64 `form:"dy_id"`
  166. Qn int `form:"qn" default:"16" validate:"min=1"`
  167. Pn int `form:"pn" default:"1" validate:"min=1"`
  168. LastTime int64 `form:"last_time"`
  169. }
  170. // FromArchive from archive to video item.
  171. func (v *VideoItem) FromArchive(arc *v1.Arc) {
  172. v.Aid = arc.Aid
  173. v.Pic = arc.Pic
  174. v.Title = arc.Title
  175. v.Duration = arc.Duration
  176. v.Author.Mid = arc.Author.Mid
  177. v.Author.Name = arc.Author.Name
  178. v.Author.Face = arc.Author.Face
  179. v.Stat.View = arc.Stat.View
  180. v.Stat.Danmaku = arc.Stat.Danmaku
  181. v.Stat.Reply = arc.Stat.Reply
  182. v.Stat.Fav = arc.Stat.Fav
  183. v.Stat.Share = arc.Stat.Share
  184. v.Stat.Like = arc.Stat.Like
  185. v.Rights = arc.Rights
  186. }