modelRT/diagram/topologic_set.go

24 lines
527 B
Go
Raw Normal View History

package diagram
import (
"errors"
"fmt"
"sync"
)
2024-11-27 15:41:22 +08:00
// GraphOverview define struct of storage all circuit diagram topologic data
var GraphOverview sync.Map
2024-11-27 15:41:22 +08:00
// GetGraphMap define func of get circuit diagram topologic data by pageID
func GetGraphMap(pageID int64) (*Graph, error) {
value, ok := GraphOverview.Load(pageID)
if !ok {
2024-11-27 15:41:22 +08:00
return nil, fmt.Errorf("can not find graph by pageID:%d", pageID)
}
graph, ok := value.(*Graph)
if !ok {
return nil, errors.New("convert to graph struct failed")
}
return graph, nil
}