material.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. package material
  2. import (
  3. xtime "go-common/library/time"
  4. )
  5. // consts .
  6. const (
  7. StateDelete = 2
  8. StateOff = 1
  9. StateOn = 0
  10. //注意 因为历史原因 bgm 和其他素材没能在bilibili_creative.material一个表集中管理 针对素材类型 为bgm保留了type=3
  11. //字幕库
  12. TypeSubTitle = int8(0)
  13. //字体库
  14. TypeFont = int8(1)
  15. //滤镜库
  16. TypeFilter = int8(2)
  17. //bgm库
  18. TypeBGM = int8(3)
  19. //热词
  20. TypeHotWord = int8(4)
  21. //拍摄贴纸 ext 新增贴纸类型 默认为0 普通贴纸,存储格式是bitmask参考属性位 0普通 1人脸 2手势 3画面效果 (不是自然数顺序 服务端不校验)
  22. TypeSticks = int8(5)
  23. //贴纸Icon
  24. TypeSticksIcon = int8(6)
  25. //投稿贴纸
  26. TypeCreativeSticks = int8(7)
  27. //投稿转场
  28. TypeCreativeTransition = int8(8)
  29. //合拍库
  30. TypeCooperate = int8(9)
  31. //主题库
  32. TypeTheme = int8(10)
  33. )
  34. var (
  35. _materialtype = map[int8]string{
  36. TypeSubTitle: "字幕库",
  37. TypeFont: "字体库",
  38. TypeFilter: "滤镜库",
  39. TypeBGM: "bgm库",
  40. TypeHotWord: "热词",
  41. TypeSticks: "贴纸",
  42. TypeSticksIcon: "贴纸Icon",
  43. TypeCreativeSticks: "投稿贴纸",
  44. TypeCreativeTransition: "投稿转场",
  45. TypeCooperate: "合拍库",
  46. TypeTheme: "主题库",
  47. }
  48. )
  49. // InMaterialType in correct materialtype.
  50. func InMaterialType(cate int8) (ok bool) {
  51. _, ok = _materialtype[cate]
  52. return
  53. }
  54. // Material model is the model for Material
  55. type Material struct {
  56. ID int64 `json:"id" form:"id" gorm:"column:id"`
  57. UID int64 `json:"uid" form:"id" gorm:"column:uid"`
  58. Name string `json:"name" form:"name" gorm:"column:name"`
  59. Extra string `json:"extra" form:"extra" gorm:"column:extra"`
  60. Rank int `json:"rank" form:"rank" gorm:"column:rank"`
  61. Type int8 `json:"type" form:"type" gorm:"column:type"`
  62. Platform int `json:"platform" form:"platform" gorm:"column:platform"`
  63. Build string `json:"build" form:"build" gorm:"column:build"`
  64. State int8 `json:"state" form:"state" gorm:"column:state"`
  65. CategoryID int64 `json:"category_id" gorm:"-"`
  66. CategoryIndex int64 `json:"category_index" gorm:"-"`
  67. CategoryName string `json:"category_name" gorm:"-"`
  68. CTime xtime.Time `json:"ctime" form:"ctime" gorm:"column:ctime"`
  69. MTime xtime.Time `json:"mtime" form:"mtime" gorm:"column:mtime"`
  70. }
  71. // TableName is used to identify table name in gorm
  72. func (Material) TableName() string {
  73. return "material"
  74. }
  75. // Result def.
  76. type Result struct {
  77. Items []*Material `json:"items"`
  78. Pager *Pager `json:"pager"`
  79. }
  80. // Pager Pager def.
  81. type Pager struct {
  82. Num int `json:"num"`
  83. Size int `json:"size"`
  84. Total int64 `json:"total"`
  85. }
  86. // Param is used to parse user request
  87. type Param struct {
  88. ID int64 `form:"id" gorm:"column:id" json:"id"`
  89. Name string `form:"name" gorm:"column:name" json:"name"`
  90. Extra string `form:"extra" gorm:"column:extra" json:"extra"`
  91. Rank int `form:"rank" gorm:"column:rank" json:"rank"`
  92. Type int8 `form:"type" gorm:"column:type" json:"type"`
  93. Cover string `form:"cover" json:"cover"`
  94. Platform int `form:"platform" json:"platform"`
  95. Build string `form:"build" json:"build"`
  96. DownloadURL string `form:"download_url" json:"download_url"`
  97. ExtraURL string `form:"extra_url" json:"extra_url"`
  98. ExtraField string `form:"extra_field" json:"extra_field"`
  99. Max int8 `form:"max" json:"max"`
  100. CategoryID int64 `form:"category_id" json:"category_id"`
  101. CategoryIndex int64 `form:"category_index" json:"category_index"`
  102. SubType int8 `form:"sub_type" json:"sub_type"`
  103. Style int8 `form:"style" json:"style"`
  104. Tip string `form:"tip" json:"tip"`
  105. WhilteList int8 `form:"white_list" json:"white_list"`
  106. MaterialAID int64 `form:"material_aid" json:"material_aid"`
  107. MaterialCID int64 `form:"material_cid" json:"material_cid"`
  108. DemoAID int64 `form:"demo_aid" json:"demo_aid"`
  109. DemoCID int64 `form:"demo_cid" json:"demo_cid"`
  110. MissionID int64 `form:"mission_id" json:"mission_id"`
  111. FilterType int8 `form:"filter_type" json:"filter_type"`
  112. }
  113. // TableName is used to identify table name in gorm
  114. func (Param) TableName() string {
  115. return "material"
  116. }