91 lines
2.8 KiB
Go
91 lines
2.8 KiB
Go
// Package network define struct of network operation
|
|
package network
|
|
|
|
import (
|
|
"modelRT/orm"
|
|
|
|
"github.com/gofrs/uuid"
|
|
)
|
|
|
|
// TopologicCreateInfo defines circuit diagram topologic create info
|
|
type TopologicCreateInfo struct {
|
|
UUIDFrom string `json:"uuid_from"`
|
|
UUIDTo string `json:"uuid_to"`
|
|
Flag int `json:"flag"`
|
|
Comment int `json:"comment"`
|
|
}
|
|
|
|
// TopologicUUIDCreateInfo defines circuit diagram topologic uuid create info
|
|
type TopologicUUIDCreateInfo struct {
|
|
UUIDFrom uuid.UUID `json:"uuid_from"`
|
|
UUIDTo uuid.UUID `json:"uuid_to"`
|
|
Flag int `json:"flag"`
|
|
Comment string `json:"comment"`
|
|
}
|
|
|
|
// ComponentCreateInfo defines circuit diagram component create info
|
|
type ComponentCreateInfo struct {
|
|
UUID string `json:"uuid"`
|
|
Name string `json:"name"`
|
|
Context map[string]any `json:"context"`
|
|
GridID int64 `json:"grid_id"`
|
|
ZoneID int64 `json:"zone_id"`
|
|
StationID int64 `json:"station_id"`
|
|
PageID int64 `json:"page_id"`
|
|
Tag string `json:"tag"`
|
|
Params string `json:"params"`
|
|
Op int `json:"op"`
|
|
}
|
|
|
|
// MeasurementCreateInfo defines circuit diagram measurement create info
|
|
type MeasurementCreateInfo struct {
|
|
UUID string `json:"uuid"`
|
|
Name string `json:"name"`
|
|
Context map[string]any `json:"context"`
|
|
GridID int64 `json:"grid_id"`
|
|
ZoneID int64 `json:"zone_id"`
|
|
StationID int64 `json:"station_id"`
|
|
PageID int64 `json:"page_id"`
|
|
Tag string `json:"tag"`
|
|
Params string `json:"params"`
|
|
Op int `json:"op"`
|
|
}
|
|
|
|
// CircuitDiagramCreateRequest defines request params of circuit diagram create api
|
|
type CircuitDiagramCreateRequest struct {
|
|
PageID int64 `json:"page_id"`
|
|
FreeVertexs []string `json:"free_vertexs"`
|
|
TopologicLinks []TopologicCreateInfo `json:"topologics"`
|
|
ComponentInfos []ComponentCreateInfo `json:"component_infos"`
|
|
}
|
|
|
|
// ConvertComponentCreateInfosToComponents define convert component create info to component struct
|
|
func ConvertComponentCreateInfosToComponents(info ComponentCreateInfo) (*orm.Component, error) {
|
|
uuidVal, err := uuid.FromString(info.UUID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
component := &orm.Component{
|
|
GlobalUUID: uuidVal,
|
|
// NsPath: info.NsPath,
|
|
Tag: info.Tag,
|
|
Name: info.Name,
|
|
// ModelName: info.ModelName,
|
|
// Description: info.Description,
|
|
// GridID: info.GridID,
|
|
// ZoneID: info.ZoneID,
|
|
// StationID: info.StationID,
|
|
// Type: info.Type,
|
|
// InService: info.InService,
|
|
// State: info.State,
|
|
// Status: info.Status,
|
|
// Connection: info.Connection,
|
|
// Label: info.Label,
|
|
Context: info.Context,
|
|
Op: info.Op,
|
|
// Ts: info.Ts,
|
|
}
|
|
return component, nil
|
|
}
|