modules.go 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. package model
  2. import (
  3. "fmt"
  4. "go-common/library/time"
  5. )
  6. const (
  7. //ModulesNotDelete module not delete
  8. ModulesNotDelete = 0
  9. //ModulesDelete module delete
  10. ModulesDelete = 1
  11. //ModulesValid module is valid
  12. ModulesValid = 1
  13. //ModulesPublishYes module is publish status in MC
  14. ModulesPublishYes = 1
  15. //ModulesPublishNo module is not publish status in MC
  16. ModulesPublishNo = 0
  17. //PageMain 主页
  18. PageMain = 0
  19. //PageJP 追番
  20. PageJP = 1
  21. //PageMovie 电影
  22. PageMovie = 2
  23. //PageDocumentary 纪录片
  24. PageDocumentary = 3
  25. //PageCN 国创
  26. PageCN = 4
  27. //PageSoapopera 电视剧
  28. PageSoapopera = 5
  29. //TypeSevenFocus 首页七格焦点图
  30. TypeSevenFocus = 1
  31. //TypeFiveFocus 5格焦点
  32. TypeFiveFocus = 2
  33. //TypeSixFocus 6格焦点
  34. TypeSixFocus = 3
  35. //TypeVertListFirst 竖图1列表
  36. TypeVertListFirst = 4
  37. //TypeVertListSecond 竖图2列表
  38. TypeVertListSecond = 5
  39. //TypeHorizList 横图列表
  40. TypeHorizList = 6
  41. //TypeZhuiFan 追番模块
  42. TypeZhuiFan = 7
  43. )
  44. // Modules is use for Modular
  45. type Modules struct {
  46. ID uint64 `json:"id"`
  47. PageID string `json:"page_id" form:"page_id" validate:"required"`
  48. Flexible string `json:"flexible" form:"flexible" validate:"required"`
  49. Icon string `json:"icon" form:"icon"`
  50. Title string `json:"title" form:"title" validate:"required"`
  51. Capacity uint64 `json:"capacity" form:"capacity" validate:"required"`
  52. More string `json:"more" form:"more" validate:"required"`
  53. Order uint8 `json:"order"`
  54. Moretype string `json:"moretype" form:"moretype"`
  55. Morepage int64 `json:"morepage" form:"morepage"`
  56. Deleted uint8 `json:"-"`
  57. Valid uint8 `json:"valid"`
  58. ModCore
  59. }
  60. // ModulesAddParam is use for Modular add param
  61. type ModulesAddParam struct {
  62. ID uint64 `form:"id" validate:"required"`
  63. PageID string `form:"page_id" validate:"required"`
  64. Flexible string `form:"flexible" validate:"required"`
  65. Icon string `form:"icon"`
  66. Title string `form:"title" validate:"required"`
  67. Capacity uint64 `form:"capacity" validate:"required"`
  68. More string `form:"more" validate:"required"`
  69. Moretype string `json:"moretype" form:"moretype"`
  70. Morepage int64 `json:"morepage" form:"morepage"`
  71. Order uint8
  72. ModCore
  73. }
  74. // ModCore def.
  75. type ModCore struct {
  76. Type string `json:"type" form:"type" validate:"required"`
  77. Source string `json:"source" form:"source" validate:"required"`
  78. SrcType int `json:"src_type" form:"src_type" validate:"required"`
  79. }
  80. //ModPub is used for store publish status
  81. type ModPub struct {
  82. Time string
  83. State uint8
  84. }
  85. //ModulesList is used for function module list
  86. type ModulesList struct {
  87. Items []*Modules `json:"items"`
  88. PubState uint8 `json:"pubstate"`
  89. PubTime string `json:"pubtime"`
  90. }
  91. // TableName tv modules
  92. func (a Modules) TableName() string {
  93. return "tv_modules"
  94. }
  95. //CommonCat , PGC types or ugc second level types
  96. type CommonCat struct {
  97. ID int32 `json:"id"`
  98. PID int32 `json:"pid"`
  99. Name string `json:"name"`
  100. Type int `json:"type"`
  101. }
  102. //ParentCat : ugc first level types
  103. type ParentCat struct {
  104. ID int32 `json:"id"`
  105. Name string `json:"name"`
  106. Type int `json:"type"`
  107. Children []*CommonCat `json:"children,omitempty"`
  108. }
  109. //SupCats : support category map
  110. type SupCats struct {
  111. UgcMap map[int32]int
  112. PgcMap map[int32]int
  113. }
  114. // AbnorCids is the export format for abnormal cids
  115. type AbnorCids struct {
  116. CID int64 `json:"cid"`
  117. VideoTitle string `json:"video_title"`
  118. CTime string `json:"ctime"`
  119. AID int64 `json:"aid"`
  120. ArcTitle string `json:"arc_title"`
  121. PubTime string `json:"pub_time"`
  122. }
  123. // Export transforms the structure to export csv data
  124. func (v *AbnorCids) Export() (res []string) {
  125. res = append(res, fmt.Sprintf("%d", v.CID))
  126. res = append(res, v.VideoTitle)
  127. res = append(res, v.CTime)
  128. res = append(res, fmt.Sprintf("%d", v.AID))
  129. res = append(res, v.ArcTitle)
  130. res = append(res, v.PubTime)
  131. return
  132. }
  133. // AbnorVideo def.
  134. type AbnorVideo struct {
  135. CID int64
  136. VideoTitle string
  137. CTime time.Time
  138. AID int64
  139. }
  140. // ToCids transforms the archive & video to abnormal cid export structure
  141. func (v *AbnorVideo) ToCids(arc *Archive) *AbnorCids {
  142. return &AbnorCids{
  143. CID: v.CID,
  144. VideoTitle: v.VideoTitle,
  145. CTime: v.CTime.Time().Format("2006-01-02 15:04:05"),
  146. AID: v.AID,
  147. ArcTitle: arc.Title,
  148. PubTime: arc.Pubtime.Time().Format("2006-01-02 15:04:05"),
  149. }
  150. }