category.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package material
  2. import (
  3. xtime "go-common/library/time"
  4. )
  5. // consts for workflow event
  6. // Category model is the model for material
  7. type Category struct {
  8. ID int64 `json:"id" gorm:"column:id"`
  9. Name string `json:"name" gorm:"column:name"`
  10. State int8 `json:"state" gorm:"column:state"`
  11. Type int64 `json:"type" gorm:"column:type"`
  12. Rank int64 `json:"rank" gorm:"column:rank"`
  13. New int64 `json:"new" gorm:"column:new"`
  14. CTime xtime.Time `json:"ctime" gorm:"column:ctime"`
  15. MTime xtime.Time `json:"mtime" gorm:"column:mtime"`
  16. }
  17. // TableName is used to identify table name in gorm
  18. func (Category) TableName() string {
  19. return "material_category"
  20. }
  21. // CategoryPager def.
  22. type CategoryPager struct {
  23. Items []*Category `json:"items"`
  24. Pager *Pager `json:"pager"`
  25. }
  26. // WithCategory model is the model for material
  27. type WithCategory struct {
  28. ID int64 `json:"id" gorm:"column:id"`
  29. CategoryID int64 `json:"category_id" gorm:"column:category_id"`
  30. MaterialID int64 `json:"material_id" gorm:"column:material_id"`
  31. State int8 `json:"state" gorm:"column:state"`
  32. Index int64 `json:"index" gorm:"column:index"`
  33. }
  34. // TableName is used to identify table name in gorm
  35. func (WithCategory) TableName() string {
  36. return "material_with_category"
  37. }
  38. // WithCategoryPager def.
  39. type WithCategoryPager struct {
  40. TotalCount int64 `json:"total_count"`
  41. Pn int `json:"pn"`
  42. Ps int `json:"ps"`
  43. Items []*WithCategory `json:"items"`
  44. }
  45. // CategoryParam is used to parse user request
  46. type CategoryParam struct {
  47. ID int64 `form:"id" gorm:"column:id"`
  48. Type int64 `form:"type" gorm:"column:type" validate:"required"`
  49. UID int64 `form:"uid" gorm:"column:uid"`
  50. Name string `form:"name" gorm:"column:name" validate:"required"`
  51. Rank int64 `form:"rank" gorm:"column:rank" validate:"required"`
  52. New int8 `form:"new" gorm:"column:new"`
  53. State int8 `form:"state" gorm:"column:state"`
  54. }
  55. // TableName is used to identify table name in gorm
  56. func (CategoryParam) TableName() string {
  57. return "material_category"
  58. }