mat_brand.go 947 B

123456789101112131415161718192021222324252627282930313233343536
  1. package models
  2. import "zhiyuan/pkg/db"
  3. type MatBrand struct {
  4. ID int `json:"id"`
  5. BrandName string `json:"brand_name"`
  6. CreatedAt int `json:"created_at"`
  7. UpdatedAt int `json:"updated_at"`
  8. }
  9. func (MatBrand) TableName() string {
  10. return "zy_mat_brand"
  11. }
  12. func (o MatBrand) GetOne(where map[string]interface{}, fields []string, retVal interface{}) (*MatBrand, error) {
  13. if retVal == nil {
  14. var matBrand *MatBrand
  15. err := db.GetOne(o.TableName(), where, fields, &matBrand)
  16. return matBrand, err
  17. } else {
  18. err := db.GetOne(o.TableName(), where, fields, retVal)
  19. return nil, err
  20. }
  21. }
  22. func (o MatBrand) GetMulti(where map[string]interface{}, fields []string, retVal interface{}) ([]*MatBrand, error) {
  23. if retVal == nil {
  24. var matBrand []*MatBrand
  25. err := db.GetMulti(o.TableName(), where, fields, &matBrand)
  26. return matBrand, err
  27. } else {
  28. err := db.GetMulti(o.TableName(), where, fields, retVal)
  29. return nil, err
  30. }
  31. }