result.go 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. package favorite
  2. import (
  3. "strconv"
  4. "go-common/app/interface/main/app-interface/model"
  5. "go-common/app/interface/main/app-interface/model/audio"
  6. "go-common/app/interface/main/app-interface/model/bplus"
  7. "go-common/app/interface/main/app-interface/model/sp"
  8. "go-common/app/interface/main/app-interface/model/topic"
  9. article "go-common/app/interface/openplatform/article/model"
  10. "go-common/app/service/main/archive/model/archive"
  11. "time"
  12. )
  13. type MyFavorite struct {
  14. Tab *Tab `json:"tab,omitempty"`
  15. Favorite *FavList `json:"favorite,omitempty"`
  16. }
  17. type Tab struct {
  18. Fav bool `json:"favorite"`
  19. Topic bool `json:"topic"`
  20. Article bool `json:"article"`
  21. Clips bool `json:"clips"`
  22. Albums bool `json:"albums"`
  23. Specil bool `json:"specil"`
  24. Cinema bool `json:"cinema"`
  25. Audios bool `json:"audios"`
  26. Menu bool `json:"menu"`
  27. PGCMenu bool `json:"pgc_menu"`
  28. Ticket bool `json:"ticket"`
  29. Product bool `json:"product"`
  30. }
  31. type FavList struct {
  32. Count int `json:"count"`
  33. Items []*FavItem `json:"items"`
  34. }
  35. type FavideoList struct {
  36. Count int `json:"count"`
  37. Items []*FavideoItem `json:"items"`
  38. }
  39. type TopicList struct {
  40. Count int `json:"count"`
  41. Items []*TopicItem `json:"items"`
  42. }
  43. type ArticleList struct {
  44. Count int `json:"count"`
  45. Items []*ArticleItem `json:"items"`
  46. }
  47. type ClipsList struct {
  48. *bplus.PageInfo
  49. Items []*ClipsItem `json:"items"`
  50. }
  51. type AlbumsList struct {
  52. *bplus.PageInfo
  53. Items []*AlbumItem `json:"items"`
  54. }
  55. type SpList struct {
  56. Count int `json:"count"`
  57. Items []*SpItem `json:"items"`
  58. }
  59. type AudioList struct {
  60. Count int `json:"count"`
  61. Items []*AudioItem `json:"items"`
  62. }
  63. func (i *FavItem) FromFav(f *Folder) {
  64. i.MediaID = f.MediaID
  65. i.Fid = f.Fid
  66. i.Mid = f.Mid
  67. i.Name = f.Name
  68. if f.Cover != nil {
  69. i.Cover = f.Cover
  70. }
  71. i.CurCount = f.CurCount
  72. i.State = f.State
  73. }
  74. type FavItem struct {
  75. MediaID int64 `json:"media_id"`
  76. Fid int `json:"fid"`
  77. Mid int `json:"mid"`
  78. Name string `json:"name"`
  79. CurCount int `json:"cur_count"`
  80. State int `json:"state"`
  81. Cover []Cover `json:"cover"`
  82. }
  83. func (i *FavideoItem) FromFavideo(fv *Archive) {
  84. i.Aid = fv.Aid
  85. i.Title = fv.Title
  86. i.Pic = fv.Pic
  87. i.Name = fv.Author.Name
  88. i.PlayNum = int(fv.Stat.View)
  89. i.Danmaku = int(fv.Stat.Danmaku)
  90. i.Param = strconv.FormatInt(int64(fv.Aid), 10)
  91. i.Goto = model.GotoAv
  92. i.URI = model.FillURI(i.Goto, i.Param, model.AvHandler(archive.BuildArchive3(fv.Arc)))
  93. i.UGCPay = fv.Rights.UGCPay
  94. }
  95. type FavideoItem struct {
  96. Aid int64 `json:"aid"`
  97. Title string `json:"title"`
  98. Pic string `json:"pic"`
  99. Name string `json:"name"`
  100. PlayNum int `json:"play_num"`
  101. Danmaku int `json:"danmaku"`
  102. Goto string `json:"goto"`
  103. Param string `json:"param"`
  104. URI string `json:"uri"`
  105. UGCPay int32 `json:"ugc_pay"`
  106. }
  107. func (i *TopicItem) FromTopic(tp *topic.List) {
  108. i.ID = tp.ID
  109. i.MID = tp.MID
  110. i.Name = tp.Name
  111. i.PCCover = tp.PCCover
  112. i.H5Cover = tp.H5Cover
  113. i.FavAt = tp.FavAt
  114. i.PCUrl = tp.PCUrl
  115. i.H5Url = tp.H5Url
  116. i.Desc = tp.Desc
  117. i.Param = strconv.FormatInt(int64(tp.ID), 10)
  118. i.Goto = model.GotoWeb
  119. i.URI = model.FillURI(i.Goto, i.Param, nil)
  120. }
  121. type TopicItem struct {
  122. ID int64 `json:"id"`
  123. MID int64 `json:"mid"`
  124. Name string `json:"name"`
  125. PCCover string `json:"pc_cover"`
  126. H5Cover string `json:"h5_cover"`
  127. FavAt int64 `json:"fav_at"`
  128. PCUrl string `json:"pc_url"`
  129. H5Url string `json:"h5_url"`
  130. Desc string `json:"desc"`
  131. Goto string `json:"goto"`
  132. Param string `json:"param"`
  133. URI string `json:"uri"`
  134. }
  135. func (i *ArticleItem) FromArticle(af *article.Favorite) {
  136. i.ID = af.ID
  137. i.Title = af.Title
  138. i.BannerURL = af.BannerURL
  139. i.TemplateID = int(af.TemplateID)
  140. i.Name = af.Author.Name
  141. i.ImageURLs = af.ImageURLs
  142. i.Summary = af.Summary
  143. i.FTime = af.FavoriteTime
  144. i.Param = strconv.FormatInt(int64(af.ID), 10)
  145. i.Goto = model.GotoArticle
  146. i.URI = model.FillURI(i.Goto, i.Param, nil)
  147. }
  148. type ArticleItem struct {
  149. ID int64 `json:"id"`
  150. Title string `json:"title"`
  151. TemplateID int `json:"template_id"`
  152. BannerURL string `json:"banner_url"`
  153. Name string `json:"name"`
  154. ImageURLs []string `json:"image_urls"`
  155. Summary string `json:"summary"`
  156. FTime int64 `json:"favorite_time"`
  157. Goto string `json:"goto"`
  158. Param string `json:"param"`
  159. URI string `json:"uri"`
  160. }
  161. func (i *ClipsItem) FromClips(c *bplus.ClipList) {
  162. i.ID = c.Content.Item.ID
  163. i.Name = c.Content.User.Name
  164. i.UID = c.Content.User.UID
  165. i.HeadURL = c.Content.User.HeadURL
  166. i.IsVIP = c.Content.User.IsVIP
  167. i.IsFollowed = c.Content.User.IsFollowed
  168. i.UploadTimeText = c.Content.Item.UploadTimeText
  169. i.Tags = c.Content.Item.Tags
  170. i.Cover = c.Content.Item.Cover
  171. i.VideoTime = c.Content.Item.VideoTime
  172. i.Desc = c.Content.Item.Desc
  173. i.DanakuNum = c.Content.Item.DanakuNum
  174. i.WatchedNum = c.Content.Item.WatchedNum
  175. i.Param = strconv.FormatInt(int64(c.Content.Item.ID), 10)
  176. i.Goto = model.GotoClip
  177. i.URI = model.FillURI(i.Goto, i.Param, nil)
  178. i.Status = c.Content.Item.ShowStatus
  179. i.Reply = c.Content.Item.Reply
  180. i.UploadTime = c.Content.Item.UploadTime
  181. i.Width = c.Content.Item.Width
  182. i.Height = c.Content.Item.Height
  183. i.FirstPic = c.Content.Item.FirstPic
  184. i.VideoPlayURL = c.Content.Item.VideoPlayURL
  185. i.BackupPlayURL = c.Content.Item.BackupPlayURL
  186. i.LikeNum = c.Content.Item.LikeNum
  187. }
  188. type ClipsItem struct {
  189. ID int64 `json:"id,omitempty"`
  190. Name string `json:"name,omitempty"`
  191. UID int64 `json:"uid,omitempty"`
  192. HeadURL string `json:"head_url,omitempty"`
  193. IsVIP int `json:"is_vip,omitempty"`
  194. UploadTimeText string `json:"upload_time_text,omitempty"`
  195. Tags []string `json:"tags,omitempty"`
  196. Cover struct {
  197. Def string `json:"default,omitempty"`
  198. } `json:"cover,omitempty"`
  199. VideoTime int `json:"video_time,omitempty"`
  200. Desc string `json:"description,omitempty"`
  201. DanakuNum int `json:"damaku_num,omitempty"`
  202. WatchedNum int `json:"watched_num,omitempty"`
  203. Goto string `json:"goto,omitempty"`
  204. Param string `json:"param,omitempty"`
  205. URI string `json:"uri,omitempty"`
  206. Status int `json:"status,omitempty"`
  207. Reply int `json:"reply,omitempty"`
  208. FirstPic string `json:"first_pic,omitempty"`
  209. BackupPlayURL []string `json:"backup_playurl,omitempty"`
  210. IsFollowed bool `json:"is_followed,omitempty"`
  211. UploadTime string `json:"upload_time,omitempty"`
  212. Width int `json:"width,omitempty"`
  213. Height int `json:"height,omitempty"`
  214. VideoPlayURL string `json:"video_playurl,omitempty"`
  215. LikeNum int `json:"like_num,omitempty"`
  216. }
  217. func (i *AlbumItem) FromAlbum(bp *bplus.AlbumList) {
  218. i.ID = bp.Content.ID
  219. i.Pic = bp.Content.Pic
  220. i.PicCount = bp.Content.PicCount
  221. i.ShowStatus = bp.Content.ShowStatus
  222. i.Param = strconv.FormatInt(int64(bp.Content.ID), 10)
  223. i.Goto = model.GotoAlbum
  224. i.URI = model.FillURI(i.Goto, i.Param, nil)
  225. }
  226. type AlbumItem struct {
  227. ID int64 `json:"id"`
  228. Pic []*bplus.Pictures `json:"pictures"`
  229. ShowStatus int `json:"show_status"`
  230. PicCount int `json:"pictures_count"`
  231. Goto string `json:"goto"`
  232. Param string `json:"param"`
  233. URI string `json:"uri"`
  234. }
  235. func (i *SpItem) FromSp(s *sp.Item) {
  236. i.SpID = s.SpID
  237. i.Title = s.Title
  238. i.Cover = s.Cover
  239. i.MCover = s.MCover
  240. i.SCover = s.SCover
  241. timeTmp, _ := time.Parse("2006-01-02 15:04", s.CTime)
  242. i.CTime = timeTmp.Unix()
  243. i.Param = strconv.FormatInt(int64(s.SpID), 10)
  244. i.Goto = model.GotoSp
  245. i.URI = model.FillURI(i.Goto, i.Param, nil)
  246. }
  247. type SpItem struct {
  248. SpID int64 `json:"spid"`
  249. Title string `json:"title"`
  250. Cover string `json:"cover"`
  251. MCover string `json:"m_cover"`
  252. SCover string `json:"s_cover"`
  253. CTime int64 `json:"create_at"`
  254. Goto string `json:"goto"`
  255. Param string `json:"param"`
  256. URI string `json:"uri"`
  257. }
  258. func (i *AudioItem) FromAudio(a *audio.FavAudio) {
  259. i.ID = a.ID
  260. i.Title = a.Title
  261. i.IsOpen = a.IsOpen
  262. i.Cover = a.ImgURL
  263. i.Count = a.RecordsNum
  264. }
  265. type AudioItem struct {
  266. ID int64 `json:"id"`
  267. Title string `json:"title"`
  268. Cover string `json:"cover"`
  269. IsOpen int `json:"is_open"`
  270. Count int `json:"count"`
  271. }
  272. type TabItem struct {
  273. Name string `json:"name"`
  274. Uri string `json:"uri"`
  275. Tab string `json:"tab"`
  276. }
  277. type TabParam struct {
  278. MobiApp string `form:"mobi_app"`
  279. Device string `form:"device"`
  280. Build int `form:"build"`
  281. Platform string `form:"platform"`
  282. Mid int64 `form:"mid"`
  283. Business string `form:"business"`
  284. AccessKey string `form:"access_key"`
  285. ActionKey string `form:"actionKey"`
  286. Filtered string `form:"filtered"`
  287. }