dangbei.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. package thirdp
  2. import (
  3. "strconv"
  4. "go-common/app/interface/main/tv/model"
  5. )
  6. // DBeiPage is the dangbei page struct
  7. type DBeiPage struct {
  8. List []*DBeiSeason `json:"list"`
  9. Pager *model.IdxPager `json:"pager"`
  10. }
  11. // DBeiSeason is the dangbei season struct
  12. type DBeiSeason struct {
  13. SeasonID *int64 `json:"cid,omitempty"`
  14. Cover string `json:"cover"`
  15. Desc string `json:"desc"`
  16. Title string `json:"title"`
  17. UpInfo string `json:"upinfo"`
  18. Category string `json:"category"` // - cn, jp, movie, tv, documentary
  19. Area string `json:"area"` // - cn, jp, others
  20. Playtime string `json:"play_time"`
  21. Role string `json:"role"`
  22. Staff string `json:"staff"`
  23. NewestOrder int `json:"newest_order"` // the newest passed ep's order
  24. NewestNB int `json:"newest_nb"`
  25. TotalNum int `json:"total_num"`
  26. Style string `json:"style"`
  27. Paystatus string `json:"pay_status"` // paid or not
  28. Official string `json:"official"` // is official or preview
  29. }
  30. // VideoCMS def.
  31. type VideoCMS struct {
  32. // Media Info
  33. CID int
  34. Title string
  35. AID int
  36. IndexOrder int
  37. // Auth Info
  38. Valid int
  39. Deleted int
  40. Result int
  41. }
  42. // PgcCat transforms the pgc category to string
  43. func PgcCat(cat int) (category string) {
  44. switch cat {
  45. case 1:
  46. category = "番剧"
  47. case 2:
  48. category = "电影"
  49. case 3:
  50. category = "纪录片"
  51. case 4:
  52. category = "国创"
  53. case 5:
  54. category = "电视剧"
  55. default:
  56. category = "其他"
  57. }
  58. return
  59. }
  60. // DBeiSn transform the object
  61. func DBeiSn(s *model.SeasonCMS) (dbei *DBeiSeason) {
  62. var (
  63. category, area string
  64. official = "正片"
  65. )
  66. category = PgcCat(int(s.Category))
  67. if s.NewestNb == 0 { // in case of job calculation fail
  68. if s.NewestOrder == 0 {
  69. s.NewestNb = s.TotalNum
  70. } else {
  71. s.NewestNb = min(s.TotalNum, s.NewestOrder)
  72. }
  73. }
  74. areaInt, _ := strconv.ParseInt(s.Area, 10, 64)
  75. if areaInt != 0 {
  76. switch areaInt {
  77. case 1:
  78. area = "中国"
  79. case 2:
  80. area = "日本"
  81. default:
  82. area = "其他"
  83. }
  84. } else {
  85. area = s.Area
  86. }
  87. dbei = &DBeiSeason{
  88. SeasonID: &s.SeasonID,
  89. Cover: s.Cover,
  90. Desc: s.Desc,
  91. Title: s.Title,
  92. UpInfo: s.UpInfo,
  93. Category: category,
  94. Area: area,
  95. Playtime: s.Playtime.Time().Format("2006-01-02"),
  96. Role: s.Role,
  97. Staff: s.Staff,
  98. NewestOrder: s.NewestOrder,
  99. NewestNB: s.NewestNb,
  100. TotalNum: s.TotalNum,
  101. Style: s.Style,
  102. Paystatus: "",
  103. Official: official,
  104. }
  105. return
  106. }
  107. // DbeiArc transforms an arc cms to dangbei season structure
  108. func DbeiArc(s *model.ArcCMS, first, second string) (dbei *DBeiSeason) {
  109. official := "正片"
  110. dbei = &DBeiSeason{
  111. SeasonID: &s.AID,
  112. Cover: s.Cover,
  113. Desc: s.Content,
  114. Title: s.Title,
  115. Category: first,
  116. Playtime: s.Pubtime.Time().Format("2006-01-02"),
  117. TotalNum: s.Videos,
  118. Style: second,
  119. Paystatus: "",
  120. Official: official,
  121. }
  122. return
  123. }
  124. // return min value
  125. func min(x, y int) int {
  126. if x < y {
  127. return x
  128. }
  129. return y
  130. }
  131. // ReqDBeiPages is request for dangbei pages
  132. type ReqDBeiPages struct {
  133. Page int64
  134. LastID int64
  135. Ps int64
  136. TypeC string
  137. }
  138. // ReqPageID is request for page ID
  139. type ReqPageID struct {
  140. Page int64
  141. ID int64
  142. TypeC string
  143. }