archive.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. package model
  2. import (
  3. "go-common/library/time"
  4. "github.com/siddontang/go-mysql/mysql"
  5. )
  6. // SimpleArc is the simple struct of archive
  7. type SimpleArc struct {
  8. ID int `gorm:"column:id"`
  9. AID int64 `gorm:"column:aid"`
  10. MID int `gorm:"column:mid"`
  11. TypeID int32 `gorm:"column:typeid"`
  12. Title string
  13. Content string
  14. Cover string
  15. Deleted int
  16. Result int
  17. Valid int
  18. Mtime time.Time
  19. Pubtime time.Time
  20. }
  21. // Archive archive def. corresponding to our table structure
  22. type Archive struct {
  23. ID int `gorm:"column:id" json:"id"`
  24. AID int64 `gorm:"column:aid" json:"aid"`
  25. MID int `gorm:"column:mid" json:"mid"`
  26. TypeID int32 `gorm:"column:typeid" json:"typeid"`
  27. Videos int `gorm:"column:videos" json:"videos"`
  28. Title string `gorm:"column:title" json:"title"`
  29. Cover string `gorm:"column:cover" json:"cover"`
  30. Content string `gorm:"column:content" json:"content"`
  31. Duration int `gorm:"column:duration" json:"duration"`
  32. Copyright int `gorm:"column:copyright" json:"copyright"`
  33. Pubtime time.Time `gorm:"column:pubtime" json:"pubtime"`
  34. InjectTime time.Time `gorm:"column:inject_time" json:"inject_time"`
  35. Ctime time.Time `gorm:"column:ctime" json:"ctime"`
  36. Mtime time.Time `gorm:"column:mtime" json:"mtime"`
  37. State int `gorm:"column:state" json:"state"`
  38. Manual int `gorm:"column:manual" json:"manual"`
  39. Valid uint8 `gorm:"column:valid" json:"valid"`
  40. Submit uint8 `gorm:"column:submit" json:"submit"`
  41. Retry int `gorm:"column:retry" json:"retry"`
  42. Result uint8 `gorm:"column:result" json:"result"`
  43. Deleted uint8 `gorm:"column:deleted" json:"deleted"`
  44. Reason string `gorm:"column:reason" json:"reason"`
  45. }
  46. // ArcPager is the result and page of archive query.
  47. type ArcPager struct {
  48. Items []*ArcList `json:"items"`
  49. Page *Page `json:"page"`
  50. }
  51. // ArcListParam is archive list request params
  52. type ArcListParam struct {
  53. ID string `form:"id" json:"id"`
  54. Title string `form:"title" json:"title"`
  55. CID string `form:"cid" json:"cid"`
  56. Typeid int32 `form:"typeid" json:"typeid"`
  57. Valid string `form:"valid" json:"valid"`
  58. Pid int32 `form:"pid" json:"-"`
  59. Order int `form:"order" json:"order" default:"2"`
  60. Mid int64 `form:"mid" json:"mid"`
  61. UpName string `form:"up_name"`
  62. PageCfg
  63. }
  64. // AddResp is for the response for adding archives/uppers
  65. type AddResp struct {
  66. Succ []int64 `json:"succ"` // successfully added ids
  67. Exist []int64 `json:"exist"` // the ids already exist in our DB
  68. Invalids []int64 `json:"invalids"` // the invalid ids ( not exist in archives/uppers )
  69. }
  70. // ArcType arctype
  71. type ArcType struct {
  72. ID int16 `json:"id"`
  73. Pid int16 `json:"pid"`
  74. Name string `json:"name"`
  75. }
  76. // ArcDB is the archive query result
  77. type ArcDB struct {
  78. ArcCore
  79. Pubdate time.Time `gorm:"column:pubtime"`
  80. }
  81. // ArcCore is the archive core struct
  82. type ArcCore struct {
  83. ID string `json:"id"`
  84. CID string `json:"cid" gorm:"column:aid"`
  85. TypeID int32 `json:"typeid" gorm:"column:typeid"`
  86. Title string `json:"title"`
  87. Valid string `json:"valid" gorm:"column:valid"`
  88. Mtime time.Time `json:"mtime"`
  89. Content string `json:"content"`
  90. Cover string `json:"cover"`
  91. MID int64 `json:"mid" gorm:"column:mid"`
  92. }
  93. // ArcList def.
  94. type ArcList struct {
  95. ArcCore
  96. PTypeID int32 `json:"parent_typeid"`
  97. Pubdate string `json:"pubdate"`
  98. UpName string `json:"up_name"`
  99. }
  100. // ToList def.
  101. func (v *ArcDB) ToList(pid int32) (res *ArcList) {
  102. return &ArcList{
  103. ArcCore: v.ArcCore,
  104. PTypeID: pid,
  105. Pubdate: v.Pubdate.Time().Format(mysql.TimeFormat),
  106. }
  107. }
  108. // UgcType ugc archive category typelist
  109. type UgcType struct {
  110. ID int32 `json:"id"`
  111. Name string `json:"name"`
  112. Children []UgcCType `json:"children"`
  113. }
  114. // UgcCType ugc archive children category type
  115. type UgcCType struct {
  116. Pid int32 `json:"pid"`
  117. ID int32 `json:"id"`
  118. Name string `json:"name"`
  119. }
  120. // Category is for getting pid and name from archive category
  121. type Category struct {
  122. Pid, Name string
  123. }
  124. // AvailTps structure in memory
  125. type AvailTps struct {
  126. PassedTps []UgcType
  127. AllTps []UgcType
  128. }
  129. // TableName ugc_archive
  130. func (v ArcDB) TableName() string {
  131. return "ugc_archive"
  132. }
  133. // TableName ugc_archive
  134. func (a SimpleArc) TableName() string {
  135. return "ugc_archive"
  136. }
  137. // TableName ugc_archive
  138. func (a Archive) TableName() string {
  139. return "ugc_archive"
  140. }