package models import ( "errors" "github.com/jinzhu/gorm" ) // Device device model // device is a product instance, which is managed by our platform type Device struct { gorm.Model RecordId string `gorm:"column:record_id;size:32;index"` // which product the device belongs to ProductID string `gorm:"column:product_id;size:32;index"` // universal device identifier, generated from vendorid-productid-deviceserial DeviceIdentifier string `sql:"type:varchar(200);not null;unique;key"` // device secret which is auto generated by the platform DeviceSecret string `sql:"type:varchar(200);not null;"` // device key is used to auth a device DeviceKey string `sql:"type:varchar(200);not null;key;"` // device name DeviceName string `sql:"type:varchar(200);not null;"` // device desc DeviceDescription string `sql:"type:text;not null;"` // device version(the agent version) DeviceVersion string `sql:"type:text;not null;"` // vendor id VendorID string `gorm:"column:vendor_id;size:32;index"` //通讯模组名称 ModuleName string } // DeviceQuery device query type DeviceQuery struct { Device ProductName string } // Devices type Devices struct { Device Status int } // DeviceChartData 设备数据图表 type DeviceChartData struct { Dt string Count int } type UpgradeParams struct { VendorID string `json:"vendor_id"` DeviceID string `json:"device_id"` File []byte `json:"file"` FileName string `json:"file_name"` FileSize int64 `json:"file_size"` } // Validate 验证 func (a *UpgradeParams) Validate() error { if a.DeviceID == "" { return errors.New("非法参数[Name, Label]") } return nil }