modelRT/orm/circuit_diagram_component.go

47 lines
2.1 KiB
Go

// Package orm define database data struct
package orm
import (
"time"
"github.com/gofrs/uuid"
)
// Component structure define abstracted info set of electrical component
type Component struct {
GlobalUUID uuid.UUID `gorm:"column:global_uuid;primaryKey;default:gen_random_uuid()"`
NSPath string `gorm:"column:nspath;type:varchar(32);not null;default:''"`
Tag string `gorm:"column:tag;type:varchar(32);not null;uniqueIndex;default:''"`
Name string `gorm:"column:name;type:varchar(64);not null;default:''"`
ModelName string `gorm:"column:model_name;type:varchar(64);not null;default:''"`
Description string `gorm:"column:description;type:varchar(512);not null;default:''"`
GridName string `gorm:"column:grid;type:varchar(64);not null;default:''"`
ZoneName string `gorm:"column:zone;type:varchar(64);not null;default:''"`
StationName string `gorm:"column:station;type:varchar(64);not null;default:''"`
StationID int64 `gorm:"column:station_id;not null"`
Type int `gorm:"column:type;not null;default:-1"`
InService bool `gorm:"column:in_service;not null;default:false"`
State int `gorm:"column:state;not null;default:-1"`
Status int `gorm:"column:status;not null;default:-1"`
Connection JSONMap `gorm:"column:connection;type:jsonb;not null;default:'{}'"`
Label JSONMap `gorm:"column:label;type:jsonb;not null;default:'{}'"`
Context JSONMap `gorm:"column:context;type:jsonb;not null;default:'{}'"`
Op int `gorm:"column:op;not null;default:-1"`
Ts time.Time `gorm:"column:ts;type:timestamptz;not null;default:current_timestamp;autoCreateTime"`
}
// TableName func respresent return table name of Component
func (c *Component) TableName() string {
return "component"
}
// GetTagName define func to inplement CircuitDiagramNodeInterface interface
func (c Component) GetTagName() string {
return c.Tag
}
// GetNSPath define func to inplement CircuitDiagramNodeInterface interface
func (c Component) GetNSPath() string {
return c.NSPath
}