substation.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package schema
  2. import (
  3. "errors"
  4. "github.com/jinzhu/gorm"
  5. )
  6. var SubstationTableName = "substations"
  7. // Substation 变电站表
  8. type Substation struct {
  9. gorm.Model
  10. StationCode string `gorm:"primary_key;not null;"` //站点编号
  11. StationName string `gorm:"not null;size:50;"` // 站点名称
  12. CompanyCode string `gorm:"not null;"` //关联公司ID
  13. CircutryCode string `gorm:"index"` //关联的线路图编号
  14. Operator string // 操作人
  15. StationIntro string `gorm:"size:255"` //备注
  16. LocationX string //经度
  17. LocationY string //纬度
  18. StationProperties JSON `sql:"TYPE:json"` //站点自定义属性
  19. PrincipalCode string `gorm:"index"` //负责人编号
  20. StationImage string //站点图片
  21. }
  22. // SubstationQuery 查询结果
  23. type SubstationQuery struct {
  24. Substation
  25. PrincipalName string
  26. PrincipalPhone string
  27. }
  28. // Validate 验证
  29. func (a *Substation) Validate() error {
  30. if a.StationName == "" ||
  31. a.CompanyCode == "" ||
  32. a.PrincipalCode == "" {
  33. return errors.New("参数不能为空")
  34. }
  35. return nil
  36. }