From ce0ef4892abd504f852814f59af9835b369d5423 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Fri, 26 Jan 2024 10:39:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E6=93=8D=E4=BD=9C=E6=97=A5=E5=BF=97?= =?UTF-8?q?oper=5Furl=E5=8F=96=E5=9C=B0=E5=9D=80=E5=8E=BB=E9=99=A4?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/framework/middleware/collectlogs/operate_log.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/framework/middleware/collectlogs/operate_log.go b/src/framework/middleware/collectlogs/operate_log.go index 65da37de..7d344b0f 100644 --- a/src/framework/middleware/collectlogs/operate_log.go +++ b/src/framework/middleware/collectlogs/operate_log.go @@ -121,7 +121,7 @@ func OperateLog(options Options) gin.HandlerFunc { BusinessType: options.BusinessType, OperatorType: options.OperatorType, Method: funcName, - OperURL: c.Request.RequestURI, + OperURL: c.Request.URL.Path, RequestMethod: c.Request.Method, OperIP: ipaddr, OperLocation: location, From 8d04665bfac341489f12c668d8595e3854979c90 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Fri, 26 Jan 2024 11:09:25 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E7=BD=91=E5=85=83=E7=8A=B6=E6=80=81?= =?UTF-8?q?map=E7=AB=9E=E4=BA=89=E8=AF=BB=E5=86=99=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../network_element/controller/ne_info.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/modules/network_element/controller/ne_info.go b/src/modules/network_element/controller/ne_info.go index 7e21666f..0c10d493 100644 --- a/src/modules/network_element/controller/ne_info.go +++ b/src/modules/network_element/controller/ne_info.go @@ -2,6 +2,7 @@ package controller import ( "fmt" + "sync" "ems.agt/src/framework/i18n" "ems.agt/src/framework/utils/ctx" @@ -26,7 +27,7 @@ type NeInfoController struct { } // 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) if err != nil { // 异常取上次缓存 - if v, ok := neStateCacheMap[neKey]; ok && v != nil { - v["online"] = false - neStateCacheMap[neKey] = v + + resDataCache, ok := neStateCacheMap.Load(neKey) + if ok && resDataCache != nil { + resDataCache.(map[string]any)["online"] = false } else { - neStateCacheMap[neKey] = map[string]any{ + resDataCache = map[string]any{ "online": false, "neId": neInfo.NeId, "neName": neInfo.NeName, @@ -65,13 +67,14 @@ func (s *NeInfoController) NeState(c *gin.Context) { "neIP": neInfo.IP, } } - c.JSON(200, result.OkData(neStateCacheMap[neKey])) + neStateCacheMap.Store(neKey, resDataCache) + c.JSON(200, result.OkData(resDataCache)) return } // 存入缓存 resData["online"] = true - neStateCacheMap[neKey] = resData + neStateCacheMap.Store(neKey, resData) c.JSON(200, result.OkData(resData)) }