view.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. package view
  2. import (
  3. "encoding/json"
  4. "strconv"
  5. arcwar "go-common/app/service/main/archive/api"
  6. )
  7. // View view+relates
  8. type View struct {
  9. *Static // relate data
  10. ReqUser *ReqUser `json:"req_user,omitempty"` // now user
  11. History *History `json:"history,omitempty"`
  12. Relates []*Relate `json:"relates,omitempty"`
  13. PID int32 `json:"category"` // father level partition ID
  14. }
  15. // ReqUser struct
  16. type ReqUser struct {
  17. Attention int `json:"attention"`
  18. Favorite int8 `json:"favorite"`
  19. Like int8 `json:"like"`
  20. Dislike int8 `json:"dislike"`
  21. Coin int8 `json:"coin"`
  22. }
  23. // Static .
  24. type Static struct {
  25. *arcwar.Arc
  26. Pages []*Page `json:"pages,omitempty"`
  27. }
  28. // Page .
  29. type Page struct {
  30. *arcwar.Page
  31. Metas []*Meta `json:"metas"`
  32. }
  33. // Meta .
  34. type Meta struct {
  35. Quality int `json:"quality"`
  36. Format string `json:"format"`
  37. Size int64 `json:"size"`
  38. }
  39. // Relate .
  40. type Relate struct {
  41. Aid int64 `json:"aid,omitempty"`
  42. Pic string `json:"pic,omitempty"`
  43. Title string `json:"title,omitempty"`
  44. Author arcwar.Author `json:"owner,omitempty"`
  45. Stat arcwar.Stat `json:"stat,omitempty"`
  46. Duration int64 `json:"duration,omitempty"`
  47. Goto string `json:"goto,omitempty"`
  48. Param string `json:"param,omitempty"`
  49. URI string `json:"uri,omitempty"`
  50. Rating float64 `json:"rating,omitempty"`
  51. Reserve string `json:"reserve,omitempty"`
  52. From string `json:"from,omitempty"`
  53. Desc string `json:"desc,omitempty"`
  54. RcmdReason string `json:"rcmd_reason,omitempty"`
  55. Badge string `json:"badge,omitempty"`
  56. Cid int64 `json:"cid,omitempty"`
  57. // cm ad
  58. AdIndex int `json:"ad_index,omitempty"`
  59. CmMark int `json:"cm_mark,omitempty"`
  60. SrcID int64 `json:"src_id,omitempty"`
  61. RequestID string `json:"request_id,omitempty"`
  62. CreativeID int64 `json:"creative_id,omitempty"`
  63. CreativeType int64 `json:"creative_type,omitempty"`
  64. Type int `json:"type,omitempty"`
  65. Cover string `json:"cover,omitempty"`
  66. ButtonTitle string `json:"button_title,omitempty"`
  67. View int `json:"view,omitempty"`
  68. Danmaku int `json:"danmaku,omitempty"`
  69. IsAd bool `json:"is_ad,omitempty"`
  70. IsAdLoc bool `json:"is_ad_loc,omitempty"`
  71. AdCb string `json:"ad_cb,omitempty"`
  72. ShowURL string `json:"show_url,omitempty"`
  73. ClickURL string `json:"click_url,omitempty"`
  74. ClientIP string `json:"client_ip,omitempty"`
  75. Extra json.RawMessage `json:"extra,omitempty"`
  76. Button *Button `json:"button,omitempty"`
  77. CardIndex int `json:"card_index,omitempty"`
  78. }
  79. // Button .
  80. type Button struct {
  81. Title string `json:"title,omitempty"`
  82. URI string `json:"uri,omitempty"`
  83. }
  84. // FromAv treatment
  85. func (r *Relate) FromAv(a *arcwar.Arc, from string) {
  86. r.Aid = a.Aid
  87. r.Title = a.Title
  88. r.Pic = a.Pic
  89. r.Author = a.Author
  90. r.Stat = a.Stat
  91. r.Duration = a.Duration
  92. r.Cid = a.FirstCid
  93. r.Goto = GotoAv
  94. r.Param = strconv.FormatInt(a.Aid, 10)
  95. r.URI = FillURI(r.Goto, r.Param, AvHandler(a))
  96. r.From = from
  97. }
  98. // History struct
  99. type History struct {
  100. Cid int64 `json:"cid"`
  101. Progress int64 `json:"progress"`
  102. }