protocal.go 532 B

123456789101112131415161718192021222324252627
  1. package models
  2. import (
  3. "errors"
  4. "github.com/jinzhu/gorm"
  5. )
  6. // Protocal 产品协议(数据点)
  7. type Protocal struct {
  8. gorm.Model
  9. Name string `gorm:"size:30;not null;"` //名称
  10. Label string `gorm:"size:20;not null;"` // 标签
  11. Type int
  12. ReadWriteType int
  13. UnitSymbol string
  14. Description string
  15. ProductID uint //所属产品
  16. }
  17. // Validate 验证
  18. func (a *Protocal) Validate() error {
  19. if a.Name == "" || a.Label == "" {
  20. return errors.New("非法参数[Name, Label]")
  21. }
  22. return nil
  23. }