package schema import ( "errors" "github.com/jinzhu/gorm" ) // Device 设备表 type Device struct { gorm.Model DeviceCode string `gorm:"not null;"` //设备code CollectorID int `gorm:"not null;"` //采集点 StationCode string `gorm:"not null;"` //归属配电室的ID DeviceName string `gorm:"not null;"` //设备名称 Status int `gorm:"size:10;not null;default:0"` //状态 0 无效 1有效 DeviceIntro string `gorm:"size:255;"` //设备备注 CompanyCode string `gorm:"not null;"` // 公司id CabinetCode string //柜体编号 SwitcherType string //开关型号 Circuitry string //线路图 PowerLevel int //电压等级 CurrentRating string //额定电流 LineSize string //导线规格 LineLength string //导线长度 Capkva string //变压器容量 Capmaterial string //导线材质 Capradius string //导线直径 Caplength string //导线长度 DeviceType string //设备类型 Password string `gorm:"not null;" json:"-"` //控制密码 } // Validate 验证 func (a *Device) Validate() error { if a.DeviceCode == "" || a.DeviceName == "" || a.CompanyCode == "" || a.StationCode == "" { return errors.New("参数不能为空") } return nil }