123456789101112131415161718192021222324252627282930313233343536373839404142 |
- package schema
- import (
- "errors"
- "github.com/jinzhu/gorm"
- )
- var SubstationTableName = "substations"
- // Substation 变电站表
- type Substation struct {
- gorm.Model
- StationCode string `gorm:"primary_key;not null;"` //站点编号
- StationName string `gorm:"not null;size:50;"` // 站点名称
- CompanyCode string `gorm:"not null;"` //关联公司ID
- CircutryCode string `gorm:"index"` //关联的线路图编号
- Operator string // 操作人
- StationIntro string `gorm:"size:255"` //备注
- LocationX string //经度
- LocationY string //纬度
- StationProperties JSON `sql:"TYPE:json"` //站点自定义属性
- PrincipalCode string `gorm:"index"` //负责人编号
- StationImage string //站点图片
- }
- // SubstationQuery 查询结果
- type SubstationQuery struct {
- Substation
- PrincipalName string
- PrincipalPhone string
- }
- // Validate 验证
- func (a *Substation) Validate() error {
- if a.StationName == "" ||
- a.CompanyCode == "" ||
- a.PrincipalCode == "" {
- return errors.New("参数不能为空")
- }
- return nil
- }
|