music.go 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. package music
  2. import (
  3. xtime "go-common/library/time"
  4. )
  5. // consts for workflow event
  6. const (
  7. MusicDelete = -100
  8. MusicOpen = 0
  9. )
  10. // Music model is the model for music
  11. type Music struct {
  12. ID int64 `json:"id" gorm:"column:id"`
  13. Sid int64 `json:"sid" gorm:"column:sid"`
  14. Name string `json:"name" gorm:"column:name"`
  15. FrontName string `json:"frontname" gorm:"column:frontname"`
  16. Musicians string `json:"musicians" gorm:"column:musicians"`
  17. Cooperate int8 `json:"cooperate" gorm:"column:cooperate"`
  18. Mid int64 `json:"mid" gorm:"column:mid"`
  19. Tid int64 `json:"tid" gorm:"-"`
  20. Tags string `json:"tags" gorm:"tags"`
  21. Timeline string `json:"timeline" gorm:"timeline"`
  22. Rid int64 `json:"rid" gorm:"-"`
  23. Pid int64 `json:"pid" gorm:"-"`
  24. Cover string `json:"cover" gorm:"column:cover"`
  25. MaterialName string `json:"material_name" gorm:"-"`
  26. CategoryName string `json:"category_name" gorm:"-"`
  27. Stat string `json:"stat" gorm:"column:stat"`
  28. Categorys string `json:"categorys" gorm:"column:categorys"`
  29. Playurl string `json:"playurl" gorm:"column:playurl"`
  30. State int8 `json:"state" gorm:"column:state"`
  31. Duration int32 `json:"duration" gorm:"column:duration"`
  32. Filesize int32 `json:"filesize" gorm:"column:filesize"`
  33. PubTime xtime.Time `json:"pubtime" gorm:"column:pubtime"`
  34. SyncTime xtime.Time `json:"synctime" gorm:"column:synctime"`
  35. CTime xtime.Time `json:"ctime" gorm:"column:ctime"`
  36. MTime xtime.Time `json:"mtime" gorm:"column:mtime"`
  37. }
  38. // TableName is used to identify table name in gorm
  39. func (Music) TableName() string {
  40. return "music"
  41. }
  42. // ResultPager def.
  43. type ResultPager struct {
  44. Items []*Music `json:"items"`
  45. Pager *Pager `json:"pager"`
  46. }
  47. // Param is used to parse user request
  48. type Param struct {
  49. ID int64 `form:"id" gorm:"column:id"`
  50. Sid int64 `form:"sid" validate:"required"`
  51. Name string `form:"name" validate:"required"`
  52. Musicians string `form:"musicians"`
  53. Mid int64 `form:"mid" validate:"required"`
  54. Cover string `form:"cover" validate:"required"`
  55. Stat string `form:"stat" `
  56. Categorys string `form:"categorys" `
  57. Playurl string `form:"playurl" `
  58. State int8 `form:"state"`
  59. Duration int32 `form:"duration" `
  60. Filesize int32 `form:"filesize" `
  61. UID int64 `form:"uid" `
  62. PubTime xtime.Time `form:"pubtime"`
  63. SyncTime xtime.Time `form:"synctime"`
  64. Tags string `form:"tags"`
  65. Timeline string `form:"timeline"`
  66. }
  67. // TableName is used to identify table name in gorm
  68. func (Param) TableName() string {
  69. return "music"
  70. }
  71. // CategoryParam is used to parse user request
  72. type CategoryParam struct {
  73. ID int64 `form:"id" gorm:"column:id"`
  74. Pid int64 `form:"pid" gorm:"column:pid"`
  75. UID int64 `form:"uid" gorm:"column:uid"`
  76. Name string `form:"name" gorm:"column:name" validate:"required"`
  77. Index int64 `form:"index" gorm:"column:index" validate:"required"`
  78. CameraIndex int64 `form:"camera_index" gorm:"column:camera_index" validate:"required"`
  79. State int8 `form:"state" gorm:"column:state"`
  80. }
  81. // TableName is used to identify table name in gorm
  82. func (CategoryParam) TableName() string {
  83. return "music_category"
  84. }
  85. // MaterialParam is used to parse user request
  86. type MaterialParam struct {
  87. ID int64 `form:"id" gorm:"column:id"`
  88. Pid int64 `form:"pid" gorm:"column:pid"`
  89. UID int64 `form:"uid" gorm:"column:uid"`
  90. Name string `form:"name" gorm:"column:name" validate:"required"`
  91. Index int64 `form:"index" gorm:"column:index"`
  92. State int8 `form:"state" gorm:"column:state"`
  93. }
  94. // TableName is used to identify table name in gorm
  95. func (MaterialParam) TableName() string {
  96. return "music_material"
  97. }
  98. // WithMaterialParam is used to parse user request
  99. type WithMaterialParam struct {
  100. ID int64 `form:"id" gorm:"column:id"`
  101. UID int64 `form:"uid" gorm:"column:uid"`
  102. Sid int64 `form:"sid" gorm:"column:sid" validate:"required,min=1"`
  103. Tid int64 `form:"tid" gorm:"column:tid" validate:"required,min=1"`
  104. Index int64 `form:"index" gorm:"column:index"`
  105. State int8 `form:"state" gorm:"column:state"`
  106. }
  107. // IndexParam is used to parse user request
  108. type IndexParam struct {
  109. ID int64 `form:"id" validate:"required"`
  110. Index int64 `form:"index" validate:"required"`
  111. SwitchID int64 `form:"switch_id" validate:"required"`
  112. SwitchIndex int64 `form:"switch_index" validate:"required"`
  113. UID int64 `form:"uid"`
  114. }
  115. // TableName is used to identify table name in gorm
  116. func (WithMaterialParam) TableName() string {
  117. return "music_with_material"
  118. }
  119. // BatchMusicWithMaterialParam is used to parse user request
  120. type BatchMusicWithMaterialParam struct {
  121. UID int64 `form:"uid" gorm:"column:uid"`
  122. SidList string `form:"sid_list" validate:"required"`
  123. Tid int64 `form:"tid" gorm:"column:tid" validate:"required,min=1"`
  124. Index int64 `form:"index" gorm:"column:index"`
  125. State int8 `form:"state" gorm:"column:state"`
  126. }
  127. // TableName is used to identify table name in gorm
  128. func (BatchMusicWithMaterialParam) TableName() string {
  129. return "music_with_material"
  130. }
  131. // WithCategoryParam is used to parse user request
  132. type WithCategoryParam struct {
  133. ID int64 `form:"id" gorm:"column:id"`
  134. UID int64 `form:"uid" gorm:"column:uid"`
  135. Sid int64 `form:"sid" gorm:"column:sid" validate:"required,min=1"`
  136. Tid int64 `form:"tid" gorm:"column:tid" validate:"required,min=1"`
  137. Index int64 `form:"index" gorm:"column:index" default:"1"`
  138. State int8 `form:"state" gorm:"column:state"`
  139. }
  140. // BatchMusicWithCategoryParam is used to parse user request
  141. type BatchMusicWithCategoryParam struct {
  142. UID int64 `form:"uid" gorm:"column:uid"`
  143. SidList string `form:"sid_list" validate:"required"`
  144. SendList string `form:"send_list"`
  145. Tid int64 `form:"tid" gorm:"column:tid" validate:"required,min=1"`
  146. Index int64 `form:"index" gorm:"column:index" default:"1"`
  147. State int8 `form:"state" gorm:"column:state"`
  148. }
  149. // TableName is used to identify table name in gorm
  150. func (BatchMusicWithCategoryParam) TableName() string {
  151. return "music_with_category"
  152. }
  153. // TableName is used to identify table name in gorm
  154. func (WithCategoryParam) TableName() string {
  155. return "music_with_category"
  156. }
  157. // LogParam is used to parse user request
  158. type LogParam struct {
  159. ID int64 `json:"id"`
  160. UID int64 `json:"uid"`
  161. UName string `json:"uname"`
  162. Action string `json:"action"`
  163. Name string `json:"name"`
  164. }