video.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. package model
  2. import (
  3. arccli "go-common/app/service/main/archive/api"
  4. "go-common/library/time"
  5. )
  6. // Video is used from PGC video
  7. type Video struct {
  8. ID int `gorm:"column:id" json:"id"`
  9. AID int `gorm:"column:aid" json:"aid"`
  10. Eptitle string `gorm:"column:eptitle" json:"eptitle"`
  11. Description string `gorm:"column:description" json:"description"`
  12. CID int64 `gorm:"column:cid" json:"cid"`
  13. Duration int `gorm:"column:duration" json:"duration"`
  14. IndexOrder int `gorm:"column:duration" json:"index_order"`
  15. Ctime time.Time `gorm:"column:ctime" json:"ctime"`
  16. Mtime time.Time `gorm:"column:mtime" json:"mtime"`
  17. InjectTime time.Time `gorm:"column:inject_time" json:"inject_time"`
  18. Valid uint8 `gorm:"column:valid" json:"valid"`
  19. Submit uint8 `gorm:"column:submit" json:"submit"`
  20. Retry int `gorm:"column:retry" json:"retry"`
  21. Result int `gorm:"column:result" json:"result"`
  22. Deleted uint8 `gorm:"column:deleted" json:"deleted"`
  23. State int `gorm:"column:state" json:"state"`
  24. Reason string `gorm:"column:reason" json:"reason"`
  25. Manual int `gorm:"column:manual" json:"manual"`
  26. }
  27. // VideoListParam is used for vlideolist funtion param valid
  28. type VideoListParam struct {
  29. CID string `form:"cid" json:"cid"`
  30. VID string `form:"vid" json:"vid"`
  31. Typeid int16 `form:"typeid" json:"typeid"`
  32. Pid int32 `form:"pid" json:"-"`
  33. Valid string `form:"valid" json:"valid"`
  34. Order int `form:"order" json:"order" default:"2"`
  35. Pn int `form:"pn" json:"pn" default:"1"`
  36. Ps int `form:"ps" json:"ps" default:"20"`
  37. }
  38. // VideoListQuery is used for selecting the field of pgc video
  39. type VideoListQuery struct {
  40. ID string `json:"id"`
  41. VID string `json:"vid" gorm:"column:cid"`
  42. CID string `json:"cid" gorm:"column:aid"`
  43. Eptitle string `json:"eptitle"`
  44. Valid string `json:"valid" gorm:"column:valid"`
  45. Mtime time.Time `json:"mtime"`
  46. SeasonTitle string `json:"season_title" gorm:"column:title"`
  47. TypeID int32 `json:"typeid" gorm:"column:typeid"`
  48. PTypeID int32 `json:"parent_typeid"`
  49. Page int `json:"page" gorm:"column:index_order"`
  50. }
  51. // VideoListPager is used by video list function to return result and page info
  52. type VideoListPager struct {
  53. Items []*VideoListQuery `json:"items"`
  54. Page *Page `json:"page"`
  55. }
  56. // TableName ugc_video
  57. func (a VideoListQuery) TableName() string {
  58. return "ugc_video"
  59. }
  60. // TableName ugc_video
  61. func (video Video) TableName() string {
  62. return "ugc_video"
  63. }
  64. // ConsultRes transforms an archive to ArcRes
  65. func (arc *Archive) ConsultRes(dict map[int32]*arccli.Tp) (res *ArcRes) {
  66. var pid int32
  67. res = &ArcRes{}
  68. if cat, ok := dict[arc.TypeID]; ok {
  69. pid = cat.Pid
  70. res.SecondCat = cat.Name
  71. }
  72. if pid != 0 {
  73. if pcat, ok := dict[pid]; ok {
  74. res.FirstCat = pcat.Name
  75. }
  76. }
  77. res.Status = int(arc.Result)
  78. res.AVID = arc.AID
  79. res.Title = arc.Title
  80. res.PubTime = arc.Pubtime.Time().Format("2006-01-02 15:04:05")
  81. if arc.InjectTime >= 0 {
  82. res.InjectTime = arc.InjectTime.Time().Format("2006-01-02 15:04:05")
  83. }
  84. res.Reason = arc.Reason
  85. return
  86. }
  87. // ConsultRes transforms an video to VideoRes
  88. func (video *Video) ConsultRes() (res *VideoRes) {
  89. res = &VideoRes{
  90. CID: video.CID,
  91. Title: video.Eptitle,
  92. Page: video.IndexOrder,
  93. Status: video.Result,
  94. Ctime: video.Ctime.Time().Format("2006-01-02 15:04:05"),
  95. Reason: video.Reason,
  96. }
  97. if video.InjectTime >= 0 {
  98. res.InjectTime = video.InjectTime.Time().Format("2006-01-02 15:04:05")
  99. }
  100. return
  101. }