archive.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. package model
  2. import (
  3. "go-common/app/interface/main/dm2/model"
  4. tagmdl "go-common/app/interface/main/tag/model"
  5. accmdl "go-common/app/service/main/account/model"
  6. arcmdl "go-common/app/service/main/archive/api"
  7. ugcmdl "go-common/app/service/main/ugcpay/api/grpc/v1"
  8. )
  9. // View view data
  10. type View struct {
  11. // archive data
  12. *arcmdl.Arc
  13. NoCache bool `json:"no_cache"`
  14. // video data pages
  15. Pages []*arcmdl.Page `json:"pages,omitempty"`
  16. Subtitle *Subtitle `json:"subtitle"`
  17. Asset *ugcmdl.AssetQueryResp `json:"asset,omitempty"`
  18. }
  19. // AssetRelation .
  20. type AssetRelation struct {
  21. State int `json:"state"`
  22. }
  23. // Stat archive stat web struct
  24. type Stat struct {
  25. Aid int64 `json:"aid"`
  26. View interface{} `json:"view"`
  27. Danmaku int32 `json:"danmaku"`
  28. Reply int32 `json:"reply"`
  29. Fav int32 `json:"favorite"`
  30. Coin int32 `json:"coin"`
  31. Share int32 `json:"share"`
  32. Like int32 `json:"like"`
  33. NowRank int32 `json:"now_rank"`
  34. HisRank int32 `json:"his_rank"`
  35. NoReprint int32 `json:"no_reprint"`
  36. Copyright int32 `json:"copyright"`
  37. }
  38. // Detail detail data
  39. type Detail struct {
  40. View *View
  41. Card *Card
  42. Tags []*tagmdl.Tag
  43. Reply *ReplyHot
  44. Related []*arcmdl.Arc
  45. }
  46. // ArchiveUserCoins .
  47. type ArchiveUserCoins struct {
  48. Multiply int64 `json:"multiply"`
  49. }
  50. // Subtitle dm subTitle.
  51. type Subtitle struct {
  52. AllowSubmit bool `json:"allow_submit"`
  53. List []*SubtitleItem `json:"list"`
  54. }
  55. // SubtitleItem dm subTitle.
  56. type SubtitleItem struct {
  57. *model.VideoSubtitle
  58. Author *accmdl.Info `json:"author"`
  59. }
  60. // TripleRes struct
  61. type TripleRes struct {
  62. Like bool `json:"like"`
  63. Coin bool `json:"coin"`
  64. Fav bool `json:"fav"`
  65. Multiply int64 `json:"multiply"`
  66. UpID int64 `json:"-"`
  67. Anticheat bool `json:"-"`
  68. }
  69. var (
  70. // StatAllowStates archive stat allow states
  71. statAllowStates = []int32{-9, -15, -30}
  72. )
  73. // CheckAllowState check archive stat allow state
  74. func CheckAllowState(arc *arcmdl.Arc) bool {
  75. if arc.IsNormal() {
  76. return true
  77. }
  78. for _, allow := range statAllowStates {
  79. if arc.State == allow {
  80. return true
  81. }
  82. }
  83. return false
  84. }
  85. // FmtArc fmt grpc arc to archive3
  86. func FmtArc(arc *arcmdl.Arc) (data *arcmdl.Arc) {
  87. data = &arcmdl.Arc{
  88. Aid: arc.Aid,
  89. Videos: arc.Videos,
  90. TypeID: arc.TypeID,
  91. TypeName: arc.TypeName,
  92. Copyright: arc.Copyright,
  93. Pic: arc.Pic,
  94. Title: arc.Title,
  95. PubDate: arc.PubDate,
  96. Ctime: arc.Ctime,
  97. Desc: arc.Desc,
  98. State: arc.State,
  99. Access: arc.Access,
  100. Attribute: arc.Attribute,
  101. Tag: arc.Tag,
  102. Tags: arc.Tags,
  103. Duration: arc.Duration,
  104. MissionID: arc.MissionID,
  105. OrderID: arc.OrderID,
  106. RedirectURL: arc.RedirectURL,
  107. Forward: arc.Forward,
  108. Rights: arcmdl.Rights{
  109. Bp: arc.Rights.Bp,
  110. Elec: arc.Rights.Elec,
  111. Download: arc.Rights.Download,
  112. Movie: arc.Rights.Movie,
  113. Pay: arc.Rights.Pay,
  114. HD5: arc.Rights.HD5,
  115. NoReprint: arc.Rights.NoReprint,
  116. Autoplay: arc.Rights.Autoplay,
  117. UGCPay: arc.Rights.UGCPay,
  118. },
  119. Author: arcmdl.Author{
  120. Mid: arc.Author.Mid,
  121. Name: arc.Author.Name,
  122. Face: arc.Author.Face,
  123. },
  124. Stat: arcmdl.Stat{
  125. Aid: arc.Stat.Aid,
  126. View: arc.Stat.View,
  127. Danmaku: arc.Stat.Danmaku,
  128. Reply: arc.Stat.Reply,
  129. Fav: arc.Stat.Fav,
  130. Coin: arc.Stat.Coin,
  131. Share: arc.Stat.Share,
  132. NowRank: arc.Stat.NowRank,
  133. HisRank: arc.Stat.HisRank,
  134. Like: arc.Stat.Like,
  135. DisLike: arc.Stat.DisLike,
  136. },
  137. ReportResult: arc.ReportResult,
  138. Dynamic: arc.Dynamic,
  139. FirstCid: arc.FirstCid,
  140. Dimension: arcmdl.Dimension{
  141. Width: arc.Dimension.Width,
  142. Height: arc.Dimension.Height,
  143. Rotate: arc.Dimension.Rotate,
  144. },
  145. }
  146. return
  147. }