package models

import (
	"errors"

	"github.com/jinzhu/gorm"
)

// Protocal 产品协议(数据点)
type Protocal struct {
	gorm.Model
	Name          string `gorm:"size:30;not null;"` //名称
	Label         string `gorm:"size:20;not null;"` // 标签
	Type          int
	ReadWriteType int
	UnitSymbol    string
	Description   string
	ProductID     uint //所属产品
}

// Validate 验证
func (a *Protocal) Validate() error {
	if a.Name == "" || a.Label == "" {
		return errors.New("非法参数[Name, Label]")
	}
	return nil
}
