modelRT/orm/circuit_diagram_bay.go

71 lines
3.9 KiB
Go
Raw Permalink Normal View History

// Package orm define database data struct
package orm
import (
"time"
"github.com/gofrs/uuid"
)
// Bay structure define abstracted info set of electrical bay
type Bay struct {
BayUUID uuid.UUID `gorm:"column:BAY_UUID;type:uuid;primaryKey;default:gen_random_uuid()"`
Name string `gorm:"column:NAME;size:64;not null;default:''"`
Type string `gorm:"column:TYPE;size:64;not null;default:''"`
Unom float64 `gorm:"column:UNOM;not null;default:-1"`
Fla float64 `gorm:"column:FLA;not null;default:-1"`
Capacity float64 `gorm:"column:CAPACITY;not null;default:-1"`
Description string `gorm:"column:DESCRIPTION;size:512;not null;default:''"`
InService bool `gorm:"column:IN_SERVICE;not null;default:false"`
State int `gorm:"column:STATE;not null;default:-1"`
Grid string `gorm:"column:GRID;size:64;not null;default:''"`
Zone string `gorm:"column:ZONE;size:64;not null;default:''"`
Station string `gorm:"column:STATION;size:64;not null;default:''"`
Business map[string]interface{} `gorm:"column:BUSINESS;type:jsonb;not null;default:'{}'"`
Context map[string]interface{} `gorm:"column:CONTEXT;type:jsonb;not null;default:'{}'"`
FromUUIDs []uuid.UUID `gorm:"column:FROM_UUIDS;type:jsonb;not null;default:'[]'"`
ToUUIDs []uuid.UUID `gorm:"column:TO_UUIDS;type:jsonb;not null;default:'[]'"`
DevProtect []interface{} `gorm:"column:DEV_PROTECT;type:jsonb;not null;default:'[]'"`
DevFaultRecord []interface{} `gorm:"column:DEV_FAULT_RECORD;type:jsonb;not null;default:'[]'"`
DevStatus []interface{} `gorm:"column:DEV_STATUS;type:jsonb;not null;default:'[]'"`
DevDynSense []interface{} `gorm:"column:DEV_DYN_SENSE;type:jsonb;not null;default:'[]'"`
DevInstruct []interface{} `gorm:"column:DEV_INSTRUCT;type:jsonb;not null;default:'[]'"`
DevEtc []interface{} `gorm:"column:DEV_ETC;type:jsonb;not null;default:'[]'"`
Components []uuid.UUID `gorm:"column:COMPONENTS;type:uuid[];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"`
}
// TableName func respresent return table name of Bay
func (Bay) TableName() string {
return "BAY"
}
// CREATE TABLE PUBLIC.BAY (
// BAY_UUID UUID PRIMARY KEY DEFAULT GEN_RANDOM_UUID(),
// NAME VARCHAR(64) NOT NULL DEFAULT '',
// TYPE VARCHAR(64) NOT NULL DEFAULT '',
// UNOM DOUBLE PRECISION NOT NULL DEFAULT -1,
// FLA DOUBLE PRECISION NOT NULL DEFAULT -1,
// CAPACITY DOUBLE PRECISION NOT NULL DEFAULT -1,
// DESCRIPTION VARCHAR(512) NOT NULL DEFAULT '',
// IN_SERVICE BOOLEAN NOT NULL DEFAULT FALSE,
// STATE INTEGER NOT NULL DEFAULT -1,
// GRID VARCHAR(64) NOT NULL DEFAULT '',
// ZONE VARCHAR(64) NOT NULL DEFAULT '',
// STATION VARCHAR(64) NOT NULL DEFAULT '',
// BUSINESS JSONB NOT NULL DEFAULT '{}', -- for Server
// CONTEXT JSONB NOT NULL DEFAULT '{}', -- for UI
// FROM_UUIDS JSONB NOT NULL DEFAULT '[]', -- uuids
// TO_UUIDS JSONB NOT NULL DEFAULT '[]', -- uuids
// DEV_PROTECT JSONB NOT NULL DEFAULT '[]', -- devices
// DEV_FAULT_RECORD JSONB NOT NULL DEFAULT '[]', -- devices
// DEV_STATUS JSONB NOT NULL DEFAULT '[]', -- devices
// DEV_DYN_SENSE JSONB NOT NULL DEFAULT '[]', -- devices
// DEV_INSTRUCT JSONB NOT NULL DEFAULT '[]', -- devices
// DEV_ETC JSONB NOT NULL DEFAULT '[]', -- devices
// COMPONENTS UUID[] NOT NULL DEFAULT '{}',
// OP INTEGER NOT NULL DEFAULT -1,
// TS TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
// );