view.go 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. package view
  2. import (
  3. "encoding/json"
  4. "strconv"
  5. "go-common/app/interface/main/app-view/model"
  6. "go-common/app/interface/main/app-view/model/act"
  7. "go-common/app/interface/main/app-view/model/ad"
  8. "go-common/app/interface/main/app-view/model/bangumi"
  9. "go-common/app/interface/main/app-view/model/creative"
  10. "go-common/app/interface/main/app-view/model/elec"
  11. "go-common/app/interface/main/app-view/model/game"
  12. "go-common/app/interface/main/app-view/model/live"
  13. "go-common/app/interface/main/app-view/model/manager"
  14. "go-common/app/interface/main/app-view/model/special"
  15. "go-common/app/interface/main/app-view/model/tag"
  16. dm2 "go-common/app/interface/main/dm2/model"
  17. "go-common/app/service/main/archive/api"
  18. "go-common/app/service/main/archive/model/archive"
  19. resmdl "go-common/app/service/main/resource/model"
  20. "go-common/app/service/openplatform/pgc-season/api/grpc/season/v1"
  21. xtime "go-common/library/time"
  22. )
  23. // BnjView 2018
  24. type BnjView struct {
  25. BeginTime int64 `json:"begin_time"`
  26. *api.Arc
  27. // owner_ext
  28. OwnerExt OwnerExt `json:"owner_ext"`
  29. // now user
  30. ReqUser *ReqUser `json:"req_user,omitempty"`
  31. LiveRoom struct {
  32. ID int64 `json:"id"`
  33. DmServer string `json:"dm_server"`
  34. DmPort int64 `json:"dm_port"`
  35. Title string `json:"title"`
  36. Uname string `json:"uname"`
  37. Cover string `json:"cover"`
  38. } `json:"live_room"`
  39. Pages []*Page `json:"pages,omitempty"`
  40. Elec *elec.Info `json:"elec,omitempty"`
  41. Stat *api.Stat `json:"stat,omitempty"`
  42. Lottery struct {
  43. ActID int64 `json:"act_id"`
  44. Times int64 `json:"times"`
  45. Rule string `json:"rule"`
  46. List []string `json:"list"`
  47. Winners []string `json:"winners"`
  48. } `json:"lottery"`
  49. Relates []*act.Relate `json:"relates"`
  50. PastReviews []*BnjPastReview `json:"past_review"`
  51. }
  52. // BnjPastReview struct
  53. type BnjPastReview struct {
  54. AID int64 `json:"aid"`
  55. Img string `json:"img"`
  56. Title string `json:"title"`
  57. }
  58. // vip active subID.
  59. const (
  60. VIPActiveView = 1
  61. VIPActivePGC = 2
  62. VIPActiveCenter = 3
  63. )
  64. // View struct
  65. type View struct {
  66. *ViewStatic
  67. // owner_ext
  68. OwnerExt OwnerExt `json:"owner_ext"`
  69. // now user
  70. ReqUser *ReqUser `json:"req_user,omitempty"`
  71. // tag info
  72. Tag []*tag.Tag `json:"tag,omitempty"`
  73. // movie
  74. Movie *bangumi.Movie `json:"movie,omitempty"`
  75. // bangumi
  76. Season *bangumi.Season `json:"season,omitempty"`
  77. // bp
  78. Bp json.RawMessage `json:"bp,omitempty"`
  79. // elec
  80. Elec *elec.Info `json:"elec,omitempty"`
  81. // history
  82. History *History `json:"history,omitempty"`
  83. // audio
  84. Audio *Audio `json:"audio,omitempty"`
  85. // contribute data
  86. Contributions []*Contribution `json:"contributions,omitempty"`
  87. // relate data
  88. Relates []*Relate `json:"relates,omitempty"`
  89. ReturnCode string `json:"-"`
  90. UserFeature string `json:"-"`
  91. IsRec int8 `json:"-"`
  92. // dislike reason
  93. Dislikes []*Dislike `json:"dislike_reasons,omitempty"`
  94. // dm
  95. DMSeg int `json:"dm_seg,omitempty"`
  96. // paster
  97. Paster *resmdl.Paster `json:"paster,omitempty"`
  98. // player_icon
  99. PlayerIcon *PlayerIcon `json:"player_icon,omitempty"`
  100. // vip_active
  101. VIPActive string `json:"vip_active,omitempty"`
  102. // cm
  103. CMs []*CM `json:"cms,omitempty"`
  104. // cm config
  105. CMConfig *CMConfig `json:"cm_config,omitempty"`
  106. // asset
  107. Asset *Asset `json:"asset,omitempty"`
  108. ActivityURL string `json:"activity_url,omitempty"`
  109. Bgm []*creative.Bgm `json:"bgm,omitempty"`
  110. Staff []*Staff `json:"staff,omitempty"`
  111. }
  112. // Staff from cooperation
  113. type Staff struct {
  114. Mid int64 `json:"mid,omitempty"`
  115. Title string `json:"title,omitempty"`
  116. Face string `json:"face,omitempty"`
  117. Name string `json:"name,omitempty"`
  118. OfficialVerify struct {
  119. Type int `json:"type"`
  120. Desc string `json:"desc"`
  121. } `json:"official_verify"`
  122. Vip struct {
  123. Type int `json:"vipType"`
  124. DueDate int64 `json:"vipDueDate"`
  125. DueRemark string `json:"dueRemark"`
  126. AccessStatus int `json:"accessStatus"`
  127. VipStatus int `json:"vipStatus"`
  128. VipStatusWarn string `json:"vipStatusWarn"`
  129. } `json:"vip"`
  130. Attention int `json:"attention"`
  131. }
  132. // ViewStatic struct
  133. type ViewStatic struct {
  134. *archive.Archive3
  135. Pages []*Page `json:"pages,omitempty"`
  136. }
  137. // ReqUser struct
  138. type ReqUser struct {
  139. Attention int `json:"attention"`
  140. Favorite int8 `json:"favorite"`
  141. Like int8 `json:"like"`
  142. Dislike int8 `json:"dislike"`
  143. Coin int8 `json:"coin"`
  144. }
  145. // Page struct
  146. type Page struct {
  147. *archive.Page3
  148. Metas []*Meta `json:"metas"`
  149. DMLink string `json:"dmlink"`
  150. Audio *Audio `json:"audio,omitempty"`
  151. DM *dm2.SubjectInfo `json:"dm,omitempty"`
  152. }
  153. // Meta struct
  154. type Meta struct {
  155. Quality int `json:"quality"`
  156. Format string `json:"format"`
  157. Size int64 `json:"size"`
  158. }
  159. // History struct
  160. type History struct {
  161. Cid int64 `json:"cid"`
  162. Progress int64 `json:"progress"`
  163. }
  164. // CM struct
  165. type CM struct {
  166. RequestID string `json:"request_id,omitempty"`
  167. RscID int64 `json:"rsc_id,omitempty"`
  168. SrcID int64 `json:"src_id,omitempty"`
  169. IsAdLoc bool `json:"is_ad_loc,omitempty"`
  170. IsAd bool `json:"is_ad,omitempty"`
  171. CmMark int `json:"cm_mark,omitempty"`
  172. ClientIP string `json:"client_ip,omitempty"`
  173. Index int `json:"index,omitempty"`
  174. AdInfo *ad.AdInfo `json:"ad_info,omitempty"`
  175. }
  176. // CMConfig struct
  177. type CMConfig struct {
  178. AdsControl json.RawMessage `json:"ads_control,omitempty"`
  179. MonitorInfo json.RawMessage `json:"monitor_info,omitempty"`
  180. }
  181. // Dislike struct
  182. type Dislike struct {
  183. ID int `json:"reason_id"`
  184. Name string `json:"reason_name"`
  185. }
  186. // OwnerExt struct
  187. type OwnerExt struct {
  188. OfficialVerify struct {
  189. Type int `json:"type"`
  190. Desc string `json:"desc"`
  191. } `json:"official_verify,omitempty"`
  192. Live *live.Live `json:"live,omitempty"`
  193. Vip struct {
  194. Type int `json:"vipType"`
  195. DueDate int64 `json:"vipDueDate"`
  196. DueRemark string `json:"dueRemark"`
  197. AccessStatus int `json:"accessStatus"`
  198. VipStatus int `json:"vipStatus"`
  199. VipStatusWarn string `json:"vipStatusWarn"`
  200. } `json:"vip"`
  201. Assists []int64 `json:"assists"`
  202. Fans int `json:"fans"`
  203. Archives int `json:"-"`
  204. }
  205. // Relate struct
  206. type Relate struct {
  207. Aid int64 `json:"aid,omitempty"`
  208. Pic string `json:"pic,omitempty"`
  209. Title string `json:"title,omitempty"`
  210. Author *api.Author `json:"owner,omitempty"`
  211. Stat api.Stat `json:"stat,omitempty"`
  212. Duration int64 `json:"duration,omitempty"`
  213. Goto string `json:"goto,omitempty"`
  214. Param string `json:"param,omitempty"`
  215. URI string `json:"uri,omitempty"`
  216. Rating float64 `json:"rating,omitempty"`
  217. Reserve string `json:"reserve,omitempty"`
  218. From string `json:"from,omitempty"`
  219. Desc string `json:"desc,omitempty"`
  220. RcmdReason string `json:"rcmd_reason,omitempty"`
  221. Badge string `json:"badge,omitempty"`
  222. Cid int64 `json:"cid,omitempty"`
  223. SeasonType int32 `json:"season_type,omitempty"`
  224. RatingCount int32 `json:"rating_count,omitempty"`
  225. // cm ad
  226. AdIndex int `json:"ad_index,omitempty"`
  227. CmMark int `json:"cm_mark,omitempty"`
  228. SrcID int64 `json:"src_id,omitempty"`
  229. RequestID string `json:"request_id,omitempty"`
  230. CreativeID int64 `json:"creative_id,omitempty"`
  231. CreativeType int64 `json:"creative_type,omitempty"`
  232. Type int `json:"type,omitempty"`
  233. Cover string `json:"cover,omitempty"`
  234. ButtonTitle string `json:"button_title,omitempty"`
  235. View int `json:"view,omitempty"`
  236. Danmaku int `json:"danmaku,omitempty"`
  237. IsAd bool `json:"is_ad,omitempty"`
  238. IsAdLoc bool `json:"is_ad_loc,omitempty"`
  239. AdCb string `json:"ad_cb,omitempty"`
  240. ShowURL string `json:"show_url,omitempty"`
  241. ClickURL string `json:"click_url,omitempty"`
  242. ClientIP string `json:"client_ip,omitempty"`
  243. Extra json.RawMessage `json:"extra,omitempty"`
  244. Button *Button `json:"button,omitempty"`
  245. CardIndex int `json:"card_index,omitempty"`
  246. Source string `json:"-"`
  247. AvFeature json.RawMessage `json:"-"`
  248. TrackID string `json:"trackid"`
  249. }
  250. // Button struct
  251. type Button struct {
  252. Title string `json:"title,omitempty"`
  253. URI string `json:"uri,omitempty"`
  254. }
  255. // Contribution struct
  256. type Contribution struct {
  257. Aid int64 `json:"aid,omitempty"`
  258. Pic string `json:"pic,omitempty"`
  259. Title string `json:"title,omitempty"`
  260. Author api.Author `json:"owner,omitempty"`
  261. Stat api.Stat `json:"stat,omitempty"`
  262. CTime xtime.Time `json:"ctime,omitempty"`
  263. }
  264. // Audio struct
  265. type Audio struct {
  266. Title string `json:"title"`
  267. Cover string `json:"cover_url"`
  268. SongID int `json:"song_id"`
  269. Play int `json:"play_count"`
  270. Reply int `json:"reply_count"`
  271. UpperID int `json:"upper_id"`
  272. Entrance string `json:"entrance"`
  273. SongAttr int `json:"song_attr"`
  274. }
  275. // PlayerIcon struct
  276. type PlayerIcon struct {
  277. URL1 string `json:"url1,omitempty"`
  278. Hash1 string `json:"hash1,omitempty"`
  279. URL2 string `json:"url2,omitempty"`
  280. Hash2 string `json:"hash2,omitempty"`
  281. CTime xtime.Time `json:"ctime,omitempty"`
  282. }
  283. // VipPlayURL playurl token struct.
  284. type VipPlayURL struct {
  285. From string `json:"from"`
  286. Ts int64 `json:"ts"`
  287. Aid int64 `json:"aid"`
  288. Cid int64 `json:"cid"`
  289. Mid int64 `json:"mid"`
  290. VIP int `json:"vip"`
  291. SVIP int `json:"svip"`
  292. Owner int `json:"owner"`
  293. Fcs string `json:"fcs"`
  294. }
  295. // NewRelateRec struct
  296. type NewRelateRec struct {
  297. TrackID string `json:"trackid"`
  298. Oid int64 `json:"id"`
  299. Source string `json:"source"`
  300. AvFeature json.RawMessage `json:"av_feature"`
  301. Goto string `json:"goto"`
  302. Title string `json:"title"`
  303. IsDalao int8 `json:"is_dalao"`
  304. RcmdReason struct {
  305. Content string `json:"content"`
  306. } `json:"rcmd_reason"`
  307. }
  308. type Asset struct {
  309. Paid int8 `json:"paid"`
  310. Price int64 `json:"price"`
  311. Msg struct {
  312. Desc1 string `json:"desc1"`
  313. Desc2 string `json:"desc2"`
  314. } `json:"msg"`
  315. }
  316. // FromAv func
  317. func (r *Relate) FromAv(a *api.Arc, from, trackid string, ap *archive.PlayerInfo, cooperation bool) {
  318. r.Aid = a.Aid
  319. r.Title = a.Title
  320. r.Pic = a.Pic
  321. r.Author = &a.Author
  322. r.Stat = a.Stat
  323. r.Duration = a.Duration
  324. r.Cid = a.FirstCid
  325. r.Goto = model.GotoAv
  326. r.Param = strconv.FormatInt(a.Aid, 10)
  327. r.URI = model.FillURI(r.Goto, r.Param, model.AvHandler(a, trackid, ap))
  328. r.From = from
  329. if a.AttrVal(archive.AttrBitIsCooperation) == archive.AttrYes && r.Author != nil && r.Author.Name != "" && cooperation {
  330. r.Author.Name = r.Author.Name + " 等联合创作"
  331. }
  332. }
  333. // FromGame func
  334. func (r *Relate) FromGame(i *game.Info, from string) {
  335. if i.GameLink == "" {
  336. return
  337. }
  338. r.Title = "相关游戏:" + i.GameName
  339. r.Pic = i.GameIcon
  340. r.Rating = i.Grade
  341. if i.GameStatus == 1 || i.GameStatus == 2 {
  342. var reserve string
  343. if i.BookNum < 10000 {
  344. reserve = strconv.FormatInt(i.BookNum, 10) + "人预约"
  345. } else {
  346. reserve = strconv.FormatFloat(float64(i.BookNum)/10000, 'f', 1, 64) + "万人预约"
  347. }
  348. r.Reserve = reserve
  349. }
  350. r.Goto = model.GotoGame
  351. r.URI = model.FillURI(r.Goto, i.GameLink, nil)
  352. r.Param = strconv.FormatInt(i.GameBaseID, 10)
  353. r.Button = &Button{Title: "进入", URI: r.URI}
  354. r.From = from
  355. }
  356. // FromSpecial func
  357. func (r *Relate) FromSpecial(sp *special.Card, from string) {
  358. r.Title = sp.Title
  359. r.Pic = sp.Cover
  360. r.Goto = model.GotoSpecial
  361. // TODO FUCK game
  362. r.URI = model.FillURI(model.OperateType[sp.ReType], sp.ReValue, nil)
  363. r.Desc = sp.Desc
  364. r.Param = strconv.FormatInt(sp.ID, 10)
  365. r.RcmdReason = sp.Badge
  366. r.From = from
  367. }
  368. // FromOperate func
  369. func (r *Relate) FromOperate(i *NewRelateRec, a *api.Arc, info *game.Info, sp *special.Card, from string, cooperation bool) {
  370. switch i.Goto {
  371. case model.GotoAv:
  372. r.FromAv(a, from, "", nil, cooperation)
  373. case model.GotoGame:
  374. r.FromGame(info, from)
  375. case model.GotoSpecial:
  376. r.FromSpecial(sp, from)
  377. }
  378. if r.Title == "" {
  379. r.Title = i.Title
  380. }
  381. if i.RcmdReason.Content != "" {
  382. r.RcmdReason = i.RcmdReason.Content
  383. }
  384. }
  385. // FromOperate func
  386. func (r *Relate) FromOperateOld(i *manager.Relate, a *api.Arc, info *game.Info, sp *special.Card, from string, cooperation bool) {
  387. switch i.Goto {
  388. case model.GotoAv:
  389. r.FromAv(a, from, "", nil, cooperation)
  390. case model.GotoGame:
  391. r.FromGame(info, from)
  392. case model.GotoSpecial:
  393. r.FromSpecial(sp, from)
  394. }
  395. if r.Title == "" {
  396. r.Title = i.Title
  397. }
  398. if r.RcmdReason == "" {
  399. r.RcmdReason = i.RecReason
  400. }
  401. }
  402. // FromCM func
  403. func (r *Relate) FromCM(ad *ad.AdInfo) {
  404. r.AdIndex = ad.Index
  405. r.CmMark = ad.CmMark
  406. r.SrcID = ad.Source
  407. r.RequestID = ad.RequestID
  408. r.CreativeID = ad.CreativeID
  409. r.CreativeType = ad.CreativeType
  410. r.Type = ad.CardType
  411. r.URI = ad.URI
  412. r.Param = ad.Param
  413. r.Goto = model.GotoCm
  414. r.View = ad.View
  415. r.Danmaku = ad.Danmaku
  416. r.IsAd = ad.IsAd
  417. r.IsAdLoc = ad.IsAdLoc
  418. r.AdCb = ad.AdCb
  419. r.ClientIP = ad.ClientIP
  420. r.Extra = ad.Extra
  421. r.CardIndex = ad.CardIndex
  422. if ad.CreativeContent != nil {
  423. r.Aid = ad.CreativeContent.VideoID
  424. r.Cover = ad.CreativeContent.ImageURL
  425. r.Title = ad.CreativeContent.Title
  426. r.ButtonTitle = ad.CreativeContent.ButtonTitle
  427. r.Desc = ad.CreativeContent.Desc
  428. r.ShowURL = ad.CreativeContent.ShowURL
  429. r.ClickURL = ad.CreativeContent.ClickURL
  430. }
  431. }
  432. // FromCM func
  433. func (c *CM) FromCM(ad *ad.AdInfo) {
  434. c.RequestID = ad.RequestID
  435. c.RscID = ad.Resource
  436. c.SrcID = ad.Source
  437. c.IsAd = ad.IsAd
  438. c.IsAdLoc = ad.IsAdLoc
  439. c.Index = ad.Index
  440. c.CmMark = ad.CmMark
  441. c.ClientIP = ad.ClientIP
  442. c.AdInfo = ad
  443. }
  444. // FromBangumi func
  445. func (r *Relate) FromBangumi(ban *v1.CardInfoProto) {
  446. r.Title = ban.Title
  447. r.Pic = ban.NewEp.Cover
  448. r.Stat = api.Stat{
  449. Danmaku: int32(ban.Stat.Danmaku),
  450. View: int32(ban.Stat.View),
  451. Fav: int32(ban.Stat.Follow),
  452. }
  453. r.Goto = model.GotoBangumi
  454. r.Param = strconv.FormatInt(int64(ban.SeasonId), 10)
  455. r.URI = model.FillURI(r.Goto, r.Param, nil)
  456. r.SeasonType = ban.SeasonType
  457. r.Badge = ban.SeasonTypeName
  458. r.Desc = ban.NewEp.IndexShow
  459. if ban.Rating != nil {
  460. r.Rating = float64(ban.Rating.Score)
  461. r.RatingCount = ban.Rating.Count
  462. }
  463. }
  464. // TripleParam struct
  465. type TripleParam struct {
  466. MobiApp string `form:"mobi_app"`
  467. Build string `form:"build"`
  468. AID int64 `form:"aid"`
  469. Ak string `form:"access_key"`
  470. From string `form:"from"`
  471. }
  472. // TripleRes struct
  473. type TripleRes struct {
  474. Like bool `json:"like"`
  475. Coin bool `json:"coin"`
  476. Fav bool `json:"fav"`
  477. Prompt bool `json:"prompt"`
  478. Multiply int64 `json:"multiply"`
  479. UpID int64 `json:"-"`
  480. Anticheat bool `json:"-"`
  481. }
  482. // Videoshot videoshot
  483. type Videoshot struct {
  484. *archive.Videoshot
  485. Points []*creative.Points `json:"points,omitempty"`
  486. }