vendor.go 603 B

1234567891011121314151617181920212223242526272829
  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. RecordId string `gorm:"column:record_id;size:32;index"`
  11. // vendor name
  12. VendorName string `sql:"type:varchar(200);not null;"`
  13. // vendor key
  14. VendorKey string `sql:"type:varchar(200);not null;key;"`
  15. // vendor description
  16. VendorDescription string `sql:"type:text;not null;"`
  17. Products []Product
  18. }
  19. // Validate Validate
  20. func (a *Vendor) Validate() error {
  21. if a.VendorName == "" {
  22. return errors.New("参数不能为空")
  23. }
  24. return nil
  25. }