1234567891011121314151617181920212223242526272829303132333435363738 |
- package models
- import (
- "errors"
- "github.com/jinzhu/gorm"
- )
- // Product product
- // product is a abstract define of same devices made by some vendor
- type Product struct {
- gorm.Model
- RecordId string `gorm:"primary_key;column:record_id;size:32;index"`
- // which vendor
- VendorID string `gorm:"column:vendor_id;size:32;index"`
- // name
- ProductName string `sql:"type:varchar(200);not null;"`
- // desc
- ProductDescription string `sql:"type:text;not null;"`
- // product key to auth a product
- ProductKey string `sql:"type:varchar(200);not null;unique;key;"`
- // product config string (JSON)
- ProductConfig string `sql:"type:text; not null;"`
- // icon of product
- ProductImage string
- // product class
- ProductType string
- Devices []Device
- }
- // Validate 验证
- func (a *Product) Validate() error {
- if a.ProductName == "" {
- return errors.New("非法参数:[ProductName]")
- }
- return nil
- }
|