device.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package schema
  2. import (
  3. "errors"
  4. "github.com/jinzhu/gorm"
  5. )
  6. // Device 设备表
  7. type Device struct {
  8. gorm.Model
  9. DeviceCode string `gorm:"not null;"` //设备code
  10. CollectorID int `gorm:"not null;"` //采集点
  11. StationCode string `gorm:"not null;"` //归属配电室的ID
  12. DeviceName string `gorm:"not null;"` //设备名称
  13. Status int `gorm:"size:10;not null;default:0"` //状态 0 无效 1有效
  14. DeviceIntro string `gorm:"size:255;"` //设备备注
  15. CompanyCode string `gorm:"not null;"` // 公司id
  16. CabinetCode string //柜体编号
  17. SwitcherType string //开关型号
  18. Circuitry string //线路图
  19. PowerLevel int //电压等级
  20. CurrentRating string //额定电流
  21. LineSize string //导线规格
  22. LineLength string //导线长度
  23. Capkva string //变压器容量
  24. Capmaterial string //导线材质
  25. Capradius string //导线直径
  26. Caplength string //导线长度
  27. DeviceType string //设备类型
  28. Password string `gorm:"not null;" json:"-"` //控制密码
  29. }
  30. // Validate 验证
  31. func (a *Device) Validate() error {
  32. if a.DeviceCode == "" ||
  33. a.DeviceName == "" ||
  34. a.CompanyCode == "" ||
  35. a.StationCode == "" {
  36. return errors.New("参数不能为空")
  37. }
  38. return nil
  39. }