modelRT/network/circuit_diagram_create_requ...

77 lines
2.2 KiB
Go
Raw Normal View History

// Package network define struct of network operation
package network
2025-08-18 17:02:38 +08:00
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 index info
type ComponentCreateInfo struct {
UUID string `json:"uuid"`
Name string `json:"name"`
Context string `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"`
}
2025-08-18 17:02:38 +08:00
// 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
}