12345678910111213141516171819202122232425262728293031323334 |
- 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
- // which vendor
- VendorID int32
- // 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
- Devices []Device
- }
- // Validate 验证
- func (a *Product) Validate() error {
- if a.ProductName == "" {
- return errors.New("非法参数:[ProductName]")
- }
- return nil
- }
|