sy_brand.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package model
  2. import (
  3. "git.getensh.com/common/gopkgsv2/database"
  4. "gorm.io/gorm"
  5. )
  6. type SyBrandModel interface {
  7. List(db *gorm.DB, pagination *Pagination) ([]GdSyBrand, error)
  8. Update(db *gorm.DB, values interface{}) error
  9. }
  10. type GdSyBrand struct {
  11. ID int64 `gorm:"column:id" json:"id" form:"id"`
  12. Initial string `gorm:"column:initial" json:"initial" form:"initial"`
  13. BrandName string `gorm:"column:brand_name" json:"brand_name" form:"brand_name"`
  14. BrandId string `gorm:"column:brand_id" json:"brand_id" form:"brand_id"`
  15. Weight int64 `gorm:"column:weight" json:"weight" form:"weight"`
  16. HasImg int64 `gorm:"column:has_img" json:"has_img" form:"has_img"`
  17. Status int64 `gorm:"column:status" json:"status" form:"status"`
  18. UpdateTime string `gorm:"column:update_time" json:"update_time" form:"update_time"`
  19. }
  20. type defaultSyBrand struct {
  21. tableName string
  22. fields string
  23. }
  24. func NewSyBrand() SyBrandModel {
  25. return &defaultSyBrand{
  26. tableName: "t_gd_sy_brand",
  27. fields: "id, initial, brand_name, brand_id, weight, has_img, status, update_time",
  28. }
  29. }
  30. func (d *defaultSyBrand) List(db *gorm.DB, pagination *Pagination) ([]GdSyBrand, error) {
  31. var res []GdSyBrand
  32. err := database.List(db, &res, database.Option{
  33. TableName: d.tableName,
  34. Fields: d.fields,
  35. Limit: pagination.Limit,
  36. OffSet: pagination.Offset,
  37. })
  38. return res, err
  39. }
  40. func (d *defaultSyBrand) Update(db *gorm.DB, values interface{}) error {
  41. return database.Update(db, values, database.Option{
  42. TableName: d.tableName,
  43. })
  44. }