archive.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. package ugc
  2. import (
  3. v1 "go-common/app/service/main/archive/api"
  4. "go-common/library/time"
  5. )
  6. // Archive archive def. corresponding to our table structure
  7. type Archive struct {
  8. ID int
  9. AID int64
  10. MID int64
  11. TypeID int32
  12. Videos int64
  13. Title string
  14. Cover string
  15. Content string
  16. Duration int64
  17. Copyright int32
  18. Pubtime time.Time
  19. Ctime time.Time
  20. Mtime time.Time
  21. State int32
  22. Manual int
  23. Valid int
  24. Submit int
  25. Retry int
  26. Result int
  27. Deleted int
  28. }
  29. // FromArcReply def
  30. func (a *Archive) FromArcReply(arc *v1.Arc) {
  31. a.AID = arc.Aid
  32. a.MID = arc.Author.Mid
  33. a.Videos = arc.Videos
  34. a.TypeID = arc.TypeID
  35. a.Title = arc.Title
  36. a.Cover = arc.Pic
  37. a.Content = arc.Desc
  38. a.Duration = arc.Duration
  39. a.Copyright = arc.Copyright
  40. a.Pubtime = arc.PubDate
  41. a.State = arc.State
  42. }
  43. // ArcAllow is the struct used to check whether the arc is allowed to enter TV database
  44. type ArcAllow struct {
  45. Aid int64
  46. State int32
  47. Ugcpay int32
  48. Typeid int32
  49. Copyright int32
  50. }
  51. // FromArcReply takes info from grpc result
  52. func (a *ArcAllow) FromArcReply(reply *v1.Arc) {
  53. a.Aid = reply.Aid
  54. a.State = reply.State
  55. a.Ugcpay = reply.Rights.UGCPay
  56. a.Typeid = reply.TypeID
  57. a.Copyright = reply.Copyright
  58. }
  59. // FromArcmdl takes info from gorpc result
  60. func (a *ArcAllow) FromArcmdl(mdl *v1.Arc) {
  61. a.Aid = mdl.Aid
  62. a.State = mdl.State
  63. a.Ugcpay = mdl.Rights.UGCPay
  64. a.Typeid = mdl.TypeID
  65. a.Copyright = mdl.Copyright
  66. }
  67. // FromDatabus takes info from databus result ( archive-notify T )
  68. func (a *ArcAllow) FromDatabus(db *ArchDatabus) {
  69. a.Aid = db.Aid
  70. a.State = db.State
  71. a.Typeid = db.TypeID
  72. a.Copyright = db.Copyright
  73. }
  74. // FromArcFull takes info from arcFull structure ( db )
  75. func (a *ArcAllow) FromArcFull(full *ArcFull) {
  76. a.Aid = full.AID
  77. a.State = full.State
  78. a.Copyright = full.Copyright
  79. a.Typeid = full.TypeID
  80. }
  81. // FromArchive takes info from DB
  82. func (a *ArcAllow) FromArchive(arc *Archive) {
  83. a.Aid = arc.AID
  84. a.State = arc.State
  85. a.Copyright = arc.Copyright
  86. a.Typeid = arc.TypeID
  87. }
  88. // CanPlay distinguishes whether an archive can play or not
  89. func (a *ArcAllow) CanPlay() bool {
  90. return a.State >= 0 || a.State == -6
  91. }
  92. // IsOrigin distinguishes whether an archive is original or not
  93. func (a *ArcAllow) IsOrigin() bool {
  94. return a.Copyright == 1
  95. }
  96. // ArcMedia is the archive media struct in MC
  97. type ArcMedia struct {
  98. Title string
  99. AID int64
  100. Cover string
  101. TypeID int32
  102. Pubtime time.Time
  103. Videos int64
  104. Deleted int
  105. }
  106. // DelVideos is used to delete videos of an archive
  107. type DelVideos struct {
  108. AID int64
  109. CIDs []int64
  110. }
  111. // ToSimple def.
  112. func (a *Archive) ToSimple() *SimpleArc {
  113. return &SimpleArc{
  114. AID: a.AID,
  115. MID: a.MID,
  116. TypeID: a.TypeID,
  117. Videos: a.Videos,
  118. Title: a.Title,
  119. Cover: a.Cover,
  120. Content: a.Content,
  121. Duration: a.Duration,
  122. Pubtime: a.Pubtime.Time().Format("2006-01-02"),
  123. }
  124. }