vendor.go 546 B

12345678910111213141516171819202122232425262728
  1. package models
  2. import (
  3. "errors"
  4. "github.com/jinzhu/gorm"
  5. )
  6. // Vendor vendor
  7. // vendor is those who make products
  8. type Vendor struct {
  9. gorm.Model
  10. // vendor name
  11. VendorName string `sql:"type:varchar(200);not null;"`
  12. // vendor key
  13. VendorKey string `sql:"type:varchar(200);not null;key;"`
  14. // vendor description
  15. VendorDescription string `sql:"type:text;not null;"`
  16. Products []Product
  17. }
  18. // Validate Validate
  19. func (a *Vendor) Validate() error {
  20. if a.VendorName == "" {
  21. return errors.New("参数不能为空")
  22. }
  23. return nil
  24. }