history.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. package model
  2. import (
  3. "go-common/app/service/main/archive/model/archive"
  4. "go-common/library/ecode"
  5. )
  6. // const .
  7. const (
  8. // TypeUnknown unkown
  9. TypeUnknown = int8(-1)
  10. // TypeOffline offline
  11. TypeOffline = int8(0)
  12. // TypeBangumi bangumi
  13. TypeBangumi = int8(1)
  14. // TypeMovie movie
  15. TypeMovie = int8(2)
  16. // TypeUGC UGC
  17. TypeUGC = int8(3)
  18. // TypePGC PGC
  19. TypePGC = int8(4)
  20. // TypeArticle Article
  21. TypeArticle = int8(5)
  22. // TypeLive Live
  23. TypeLive = int8(6)
  24. // TypeCorpus corpus
  25. TypeCorpus = int8(7)
  26. // TypeComic comic
  27. TypeComic = int8(8)
  28. // SubTypeOffline archive subtype
  29. SubTypeOffline = int8(1)
  30. // SubTypeBangumi bangumi
  31. SubTypeBangumi = int8(1)
  32. // SubTypeFilm film
  33. SubTypeFilm = int8(2)
  34. // SubTypeDoc documentary
  35. SubTypeDoc = int8(3)
  36. // SubTypeNation nation
  37. SubTypeNation = int8(4)
  38. // SubTypeTV TV
  39. SubTypeTV = int8(5)
  40. // DeviceUnknown unknown
  41. DeviceUnknown = int8(0)
  42. // DeviceIphone iphoneTV
  43. DeviceIphone = int8(1)
  44. // DevicePC PC
  45. DevicePC = int8(2)
  46. // DeviceAndroid android
  47. DeviceAndroid = int8(3)
  48. // DeviceAndroidTV android TV
  49. DeviceAndroidTV = int8(33)
  50. // DeviceIpad ipad
  51. DeviceIpad = int8(4)
  52. // DeviceWP8 WP8
  53. DeviceWP8 = int8(5)
  54. // DeviceUWP UWP
  55. DeviceUWP = int8(6)
  56. // ShadowUnknown unknown
  57. ShadowUnknown = int64(-1)
  58. // ShadowOff off
  59. ShadowOff = int64(0)
  60. // ShadowOn on
  61. ShadowOn = int64(1)
  62. // ProComplete progress complete
  63. ProComplete = int64(-1)
  64. // PlatformAndroid platform android.
  65. PlatformAndroid string = "android"
  66. // PlatformIOS platform ios.
  67. PlatformIOS string = "ios"
  68. // DevicePad device pad.
  69. DevicePad string = "pad"
  70. // MobileAppAndroidTV mobile app android tv.
  71. MobileAppAndroidTV string = "android_tv_yst"
  72. HistoryLog = 171
  73. HistoryClear = "history_clear"
  74. HistoryClearTyp = "history_clear_%s"
  75. ToviewClear = "toview_clear"
  76. )
  77. var businesses = map[string]int8{
  78. "pgc": TypePGC,
  79. "article": TypeArticle,
  80. "archive": TypeUGC,
  81. "live": TypeLive,
  82. "article-list": TypeCorpus,
  83. "comic": TypeComic,
  84. }
  85. var businessIDs = map[int8]string{
  86. TypeOffline: "archive",
  87. TypeMovie: "pgc",
  88. TypeBangumi: "pgc",
  89. TypePGC: "pgc",
  90. TypeArticle: "article",
  91. TypeUGC: "archive",
  92. TypeLive: "live",
  93. TypeCorpus: "article-list",
  94. TypeComic: "comic",
  95. }
  96. // BusinessByTP .
  97. func BusinessByTP(b int8) string {
  98. return businessIDs[b]
  99. }
  100. // CheckBusiness .
  101. func CheckBusiness(bs string) (tp int8, err error) {
  102. if bs == "" {
  103. return
  104. }
  105. tp, ok := businesses[bs]
  106. if !ok {
  107. err = ecode.AppDenied
  108. }
  109. return
  110. }
  111. // MustCheckBusiness .
  112. func MustCheckBusiness(bs string) (tp int8, err error) {
  113. if bs == "" {
  114. err = ecode.RequestErr
  115. return
  116. }
  117. tp, ok := businesses[bs]
  118. if !ok {
  119. err = ecode.AppDenied
  120. }
  121. return
  122. }
  123. // Merge report merge in history.
  124. type Merge struct {
  125. Mid int64 `json:"mid"`
  126. Now int64 `json:"now"`
  127. }
  128. // Video video history.
  129. type Video struct {
  130. *archive.Archive3
  131. Favorite bool `json:"favorite"` // video favorite
  132. TP int8 `json:"type"` // video type
  133. STP int8 `json:"sub_type"` // video type
  134. DT int8 `json:"device"` // device type
  135. Page *archive.Page3 `json:"page,omitempty"`
  136. Count int `json:"count,omitempty"`
  137. BangumiInfo *Bangumi `json:"bangumi,omitempty"`
  138. Progress int64 `json:"progress"`
  139. ViewAt int64 `json:"view_at"`
  140. }
  141. // Season season.
  142. type Season struct {
  143. ID int64 `json:"season_id"`
  144. Title string `json:"title"`
  145. SeasonStatus int `json:"season_status"`
  146. IsFinish int `json:"is_finish"`
  147. TotalCount int32 `json:"total_count"`
  148. NewestEpid int64 `json:"newest_ep_id"`
  149. NewestEpIndex string `json:"newest_ep_index"`
  150. SeasonType int `json:"season_type,omitempty"`
  151. Mode int `json:"mode,omitempty"`
  152. }
  153. // Bangumi bangumi.
  154. type Bangumi struct {
  155. Epid int64 `json:"ep_id"`
  156. Title string `json:"title"`
  157. LongTitle string `json:"long_title"`
  158. EpisodeStatus int `json:"episode_status"`
  159. Follow int `json:"follow"`
  160. Cover string `json:"cover"`
  161. Season *Season `json:"season"`
  162. }
  163. // BangumiSeason season.
  164. type BangumiSeason struct {
  165. ID int64 `json:"season_id"`
  166. Epid int64 `json:"episode_id"`
  167. EpidType int64 `json:"season_type"`
  168. }