fix bug of circuit diagram load handler
This commit is contained in:
parent
ac5d508171
commit
f48b527708
|
|
@ -9,6 +9,14 @@ import (
|
|||
// graphOverview define struct of storage all circuit diagram topologic data
|
||||
var graphOverview sync.Map
|
||||
|
||||
// PrintGrapMap define func of print circuit diagram topologic info data
|
||||
func PrintGrapMap() {
|
||||
graphOverview.Range(func(key, value interface{}) bool {
|
||||
fmt.Println(key, value)
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
// GetGraphMap define func of get circuit diagram topologic data by pageID
|
||||
func GetGraphMap(pageID int64) (*Graph, error) {
|
||||
value, ok := graphOverview.Load(pageID)
|
||||
|
|
|
|||
|
|
@ -76,6 +76,23 @@ func CircuitDiagramLoadHandler(c *gin.Context) {
|
|||
componentParamMap[UUIDStr] = componentParams
|
||||
}
|
||||
}
|
||||
|
||||
rootVertexUUID := topologicInfo.RootVertex.String()
|
||||
rootComponentParam, err := diagram.GetComponentMap(rootVertexUUID)
|
||||
if err != nil {
|
||||
logger.Error("get component data from set by uuid failed", zap.Error(err))
|
||||
header := network.FailResponseHeader{Status: http.StatusBadRequest, ErrMsg: err.Error()}
|
||||
resp := network.FailureResponse{
|
||||
FailResponseHeader: header,
|
||||
PayLoad: map[string]interface{}{
|
||||
"uuid": rootVertexUUID,
|
||||
},
|
||||
}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
return
|
||||
}
|
||||
componentParamMap[rootVertexUUID] = rootComponentParam
|
||||
|
||||
payLoad["component_params"] = componentParamMap
|
||||
|
||||
resp := network.SuccessResponse{
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ var ParseFunc = func(parseConfig interface{}) {
|
|||
unmarshalMap := make(map[string]interface{})
|
||||
tableName := model.SelectModelNameByType(modelParseConfig.ComponentInfo.ComponentType)
|
||||
|
||||
result := pgClient.WithContext(cancelCtx).Table(tableName).Where("global_uuid = ?", modelParseConfig.ComponentInfo.GlobalUUID).Find(&unmarshalMap)
|
||||
result := pgClient.WithContext(cancelCtx).Table(tableName).Where("component_id = ?", modelParseConfig.ComponentInfo.ID).Find(&unmarshalMap)
|
||||
if result.Error != nil {
|
||||
logger.Error("query component detail info failed", zap.Error(result.Error))
|
||||
return
|
||||
|
|
|
|||
Loading…
Reference in New Issue