fix bug of load component info
This commit is contained in:
parent
d9cc5f3738
commit
375655017e
13
main.go
13
main.go
|
|
@ -91,11 +91,24 @@ func main() {
|
|||
|
||||
engine := gin.Default()
|
||||
engine.Use(limiter.Middleware)
|
||||
|
||||
// diagram api
|
||||
engine.GET("/model/diagram_load", handler.CircuitDiagramLoadHandler)
|
||||
engine.POST("/model/diagram_create", handler.CircuitDiagramCreateHandler)
|
||||
engine.POST("/model/diagram_update", handler.CircuitDiagramUpdateHandler)
|
||||
engine.POST("/model/diagram_delete", handler.CircuitDiagramDeleteHandler)
|
||||
|
||||
// dashborad api
|
||||
dashboard := engine.Group("/dashboard", limiter.Middleware)
|
||||
{
|
||||
dashboard.GET("/load", nil)
|
||||
dashboard.GET("/query", nil)
|
||||
dashboard.POST("/create", nil)
|
||||
dashboard.POST("/update", nil)
|
||||
dashboard.POST("/delete", nil)
|
||||
}
|
||||
|
||||
// engine.Group()
|
||||
// Swagger UI
|
||||
engine.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import (
|
|||
"modelRT/diagram"
|
||||
"modelRT/model"
|
||||
|
||||
cmap "github.com/orcaman/concurrent-map/v2"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
|
|
@ -26,12 +27,8 @@ var ParseFunc = func(parseConfig interface{}) {
|
|||
cancelCtx, cancel := context.WithTimeout(modelParseConfig.Context, 5*time.Second)
|
||||
defer cancel()
|
||||
pgClient := database.GetPostgresDBClient()
|
||||
componentKey := modelParseConfig.ComponentInfo.GlobalUUID.String()
|
||||
unmarshalMap, err := diagram.GetComponentMap(componentKey)
|
||||
if err != nil {
|
||||
logger.Error("get component map from overviewMap failed", zap.String("component_key", componentKey), zap.Error(err))
|
||||
panic(err)
|
||||
}
|
||||
uuid := modelParseConfig.ComponentInfo.GlobalUUID.String()
|
||||
unmarshalMap := cmap.New[any]()
|
||||
|
||||
tableName := model.SelectModelNameByType(modelParseConfig.ComponentInfo.ComponentType)
|
||||
result := pgClient.Table(tableName).WithContext(cancelCtx).Find(&unmarshalMap)
|
||||
|
|
@ -41,6 +38,7 @@ var ParseFunc = func(parseConfig interface{}) {
|
|||
logger.Error("query component detail info from table is empty", zap.String("table_name", tableName))
|
||||
}
|
||||
unmarshalMap.Set("id", modelParseConfig.ComponentInfo.ID)
|
||||
unmarshalMap.Set("uuid", modelParseConfig.ComponentInfo.GlobalUUID.String())
|
||||
unmarshalMap.Set("created_time", modelParseConfig.ComponentInfo.VisibleID)
|
||||
unmarshalMap.Set("parent_id", modelParseConfig.ComponentInfo.GridID)
|
||||
unmarshalMap.Set("type", modelParseConfig.ComponentInfo.ZoneID)
|
||||
|
|
@ -53,5 +51,7 @@ var ParseFunc = func(parseConfig interface{}) {
|
|||
unmarshalMap.Set("id", modelParseConfig.ComponentInfo.Context)
|
||||
unmarshalMap.Set("parent_id", modelParseConfig.ComponentInfo.Comment)
|
||||
unmarshalMap.Set("type", modelParseConfig.ComponentInfo.InService)
|
||||
|
||||
diagram.StoreComponentMap(uuid, &unmarshalMap)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue