init attribute key struct
This commit is contained in:
parent
8520790989
commit
1b6211b34b
|
|
@ -0,0 +1,9 @@
|
||||||
|
// Package constants define constant variable
|
||||||
|
package constants
|
||||||
|
|
||||||
|
const (
|
||||||
|
// ShortAttrKeyLenth define short attribute key length
|
||||||
|
ShortAttrKeyLenth int = 4
|
||||||
|
// LongAttrKeyLenth define long attribute key length
|
||||||
|
LongAttrKeyLenth int = 7
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
// Package model define model struct of model runtime service
|
||||||
|
package model
|
||||||
|
|
||||||
|
import "modelRT/orm"
|
||||||
|
|
||||||
|
// AttrModelInterface define basic attr model type interface
|
||||||
|
type AttrModelInterface interface {
|
||||||
|
GetGridInfo() *orm.Grid
|
||||||
|
GetZoneInfo() *orm.Zone
|
||||||
|
GetStationInfo() *orm.Station
|
||||||
|
GetComponentInfo() *orm.Component
|
||||||
|
IsLocal() bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// LongAttrInfo structure define long attribute key info of component
|
||||||
|
type LongAttrInfo struct {
|
||||||
|
AttrKey string `json:"attr_key"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ShortAttrInfo structure define short attribute key info of component
|
||||||
|
type ShortAttrInfo struct {
|
||||||
|
AttrKey string `json:"attr_key"`
|
||||||
|
}
|
||||||
|
|
@ -9,21 +9,32 @@ import (
|
||||||
|
|
||||||
// Component structure define abstracted info set of electrical component
|
// Component structure define abstracted info set of electrical component
|
||||||
type Component struct {
|
type Component struct {
|
||||||
ID int64 `gorm:"column:id;primaryKey"`
|
GlobalUUID uuid.UUID `gorm:"column:GLOBAL_UUID;primaryKey"`
|
||||||
GlobalUUID uuid.UUID `gorm:"column:global_uuid"`
|
NsPath string `gorm:"column:NSPATH"`
|
||||||
Tag string `gorm:"column:tag"`
|
Tag string `gorm:"column:TAG"`
|
||||||
GridID string `gorm:"column:grid"`
|
Name string `gorm:"column:NAME"`
|
||||||
ZoneID string `gorm:"column:zone"`
|
ModelName string `gorm:"column:MODEL_NAME"`
|
||||||
StationID string `gorm:"column:station"`
|
Description string `gorm:"column:DESCRIPTION"`
|
||||||
PageID int64 `gorm:"column:page_id"`
|
GridID string `gorm:"column:GRID"`
|
||||||
ComponentType int `gorm:"column:type"`
|
ZoneID string `gorm:"column:ZONE"`
|
||||||
Name string `gorm:"column:name"`
|
StationID string `gorm:"column:STATION"`
|
||||||
Context string `gorm:"column:context"`
|
Type int `gorm:"column:TYPE"`
|
||||||
Op int `gorm:"column:op"`
|
InService bool `gorm:"column:IN_SERVICE"`
|
||||||
Ts time.Time `gorm:"column:ts"`
|
State int `gorm:"column:STATE"`
|
||||||
|
Status int `gorm:"column:STATUS"`
|
||||||
|
Connection map[string]interface{} `gorm:"column:CONNECTION;type:jsonb;default:'{}'"`
|
||||||
|
Label map[string]interface{} `gorm:"column:LABEL;type:jsonb;default:'{}'"`
|
||||||
|
Context string `gorm:"column:CONTEXT"`
|
||||||
|
Op int `gorm:"column:OP"`
|
||||||
|
Ts time.Time `gorm:"column:TS"`
|
||||||
|
|
||||||
|
// TODO 解决删除ID、ComponentType、PageID后的报错
|
||||||
|
ID int64 `gorm:"column:id;primaryKey"`
|
||||||
|
PageID int64 `gorm:"column:page_id"`
|
||||||
|
ComponentType int `gorm:"column:TYPE"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TableName func respresent return table name of Component
|
// TableName func respresent return table name of Component
|
||||||
func (c *Component) TableName() string {
|
func (c *Component) TableName() string {
|
||||||
return "component"
|
return "COMPONENT"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
// Package orm define database data struct
|
||||||
|
package orm
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Grid structure define abstracted info set of electrical grid
|
||||||
|
type Grid struct {
|
||||||
|
ID int64 `gorm:"column:ID;primaryKey"`
|
||||||
|
Name string `gorm:"column:NAME"`
|
||||||
|
Description string `gorm:"column:DESCRIPTION"`
|
||||||
|
Op int `gorm:"column:OP"`
|
||||||
|
Ts time.Time `gorm:"column:TS"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TableName func respresent return table name of Grid
|
||||||
|
func (g *Grid) TableName() string {
|
||||||
|
return "GRID"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
// Package orm define database data struct
|
||||||
|
package orm
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Station structure define abstracted info set of electrical Station
|
||||||
|
type Station struct {
|
||||||
|
ID int64 `gorm:"column:ID;primaryKey"`
|
||||||
|
ZoneID int64 `gorm:"column:ZONE_ID"`
|
||||||
|
Name string `gorm:"column:NAME"`
|
||||||
|
Description string `gorm:"column:DESCRIPTION"`
|
||||||
|
IsLocal bool `gorm:"column:IS_LOCAL"`
|
||||||
|
Op int `gorm:"column:OP"`
|
||||||
|
Ts time.Time `gorm:"column:TS"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TableName func respresent return table name of Station
|
||||||
|
func (s *Station) TableName() string {
|
||||||
|
return "STATION"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
// Package orm define database data struct
|
||||||
|
package orm
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Zone structure define abstracted info set of electrical zone
|
||||||
|
type Zone struct {
|
||||||
|
ID int64 `gorm:"column:ID;primaryKey"`
|
||||||
|
GridID int64 `gorm:"column:GRID_ID"`
|
||||||
|
Name string `gorm:"column:NAME"`
|
||||||
|
Description string `gorm:"column:DESCRIPTION"`
|
||||||
|
Op int `gorm:"column:OP"`
|
||||||
|
Ts time.Time `gorm:"column:TS"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TableName func respresent return table name of Zone
|
||||||
|
func (z *Zone) TableName() string {
|
||||||
|
return "ZONE"
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue