package models import ( "errors" "github.com/jinzhu/gorm" ) // Vendor vendor // vendor is those who make products type Vendor struct { gorm.Model RecordId string `gorm:"primary_key;column:record_id;size:32;index"` // vendor name VendorName string `sql:"type:varchar(200);not null;"` // vendor key VendorKey string `sql:"type:varchar(200);not null;key;"` // vendor description VendorDescription string `sql:"type:text;not null;"` Products []Product } // Validate Validate func (a *Vendor) Validate() error { if a.VendorName == "" { return errors.New("参数不能为空") } return nil }