Merge branch 'main' of http://192.168.2.166:3180/OMC/ems_backend
This commit is contained in:
@@ -121,7 +121,7 @@ func OperateLog(options Options) gin.HandlerFunc {
|
|||||||
BusinessType: options.BusinessType,
|
BusinessType: options.BusinessType,
|
||||||
OperatorType: options.OperatorType,
|
OperatorType: options.OperatorType,
|
||||||
Method: funcName,
|
Method: funcName,
|
||||||
OperURL: c.Request.RequestURI,
|
OperURL: c.Request.URL.Path,
|
||||||
RequestMethod: c.Request.Method,
|
RequestMethod: c.Request.Method,
|
||||||
OperIP: ipaddr,
|
OperIP: ipaddr,
|
||||||
OperLocation: location,
|
OperLocation: location,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package controller
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"ems.agt/src/framework/i18n"
|
"ems.agt/src/framework/i18n"
|
||||||
"ems.agt/src/framework/utils/ctx"
|
"ems.agt/src/framework/utils/ctx"
|
||||||
@@ -26,7 +27,7 @@ type NeInfoController struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// neStateCacheMap 网元状态缓存最后一次成功的信息
|
// neStateCacheMap 网元状态缓存最后一次成功的信息
|
||||||
var neStateCacheMap map[string]map[string]any = make(map[string]map[string]any)
|
var neStateCacheMap = sync.Map{}
|
||||||
|
|
||||||
// 网元状态
|
// 网元状态
|
||||||
//
|
//
|
||||||
@@ -53,11 +54,12 @@ func (s *NeInfoController) NeState(c *gin.Context) {
|
|||||||
resData, err := neService.NeState(neInfo)
|
resData, err := neService.NeState(neInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// 异常取上次缓存
|
// 异常取上次缓存
|
||||||
if v, ok := neStateCacheMap[neKey]; ok && v != nil {
|
|
||||||
v["online"] = false
|
resDataCache, ok := neStateCacheMap.Load(neKey)
|
||||||
neStateCacheMap[neKey] = v
|
if ok && resDataCache != nil {
|
||||||
|
resDataCache.(map[string]any)["online"] = false
|
||||||
} else {
|
} else {
|
||||||
neStateCacheMap[neKey] = map[string]any{
|
resDataCache = map[string]any{
|
||||||
"online": false,
|
"online": false,
|
||||||
"neId": neInfo.NeId,
|
"neId": neInfo.NeId,
|
||||||
"neName": neInfo.NeName,
|
"neName": neInfo.NeName,
|
||||||
@@ -65,13 +67,14 @@ func (s *NeInfoController) NeState(c *gin.Context) {
|
|||||||
"neIP": neInfo.IP,
|
"neIP": neInfo.IP,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.JSON(200, result.OkData(neStateCacheMap[neKey]))
|
neStateCacheMap.Store(neKey, resDataCache)
|
||||||
|
c.JSON(200, result.OkData(resDataCache))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 存入缓存
|
// 存入缓存
|
||||||
resData["online"] = true
|
resData["online"] = true
|
||||||
neStateCacheMap[neKey] = resData
|
neStateCacheMap.Store(neKey, resData)
|
||||||
c.JSON(200, result.OkData(resData))
|
c.JSON(200, result.OkData(resData))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user