From 4ecdda946849236a0642c83c27e6b3538ba50153 Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Sun, 1 Jun 2025 16:53:29 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=B8=AD=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/userService.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/service/userService.go b/service/userService.go index 4bfd932..f95cfb5 100644 --- a/service/userService.go +++ b/service/userService.go @@ -410,11 +410,12 @@ func GetUserByIDFromUserCenter(id int) dao.User { var user dao.User //先从redis获取 key := "user_info_" + strconv.Itoa(id) - user_str := worker.GetRedis(key) - if user_str != "" { - err := json.Unmarshal([]byte(user_str), &user) + userStr := worker.GetRedis(key) + log.Println("user_str:", userStr) + if userStr != "" { + err := json.Unmarshal([]byte(userStr), &user) if err != nil { - fmt.Println("get user info , json unmarshal error:", err, "\tuser_str:", user_str) + fmt.Println("get user info , json unmarshal error:", err, "\tuser_str:", userStr) return dao.User{} } } else { @@ -425,14 +426,16 @@ func GetUserByIDFromUserCenter(id int) dao.User { fmt.Println("get user info , json marshal error:", err) return dao.User{} } - user_str = string(userJson) - success := worker.SetRedisWithExpire(key, user_str, time.Second*10) + userStr = string(userJson) + success := worker.SetRedisWithExpire(key, userStr, time.Second*10) if !success { - fmt.Println("set redis error,user json:", user_str) + fmt.Println("set redis error,user json:", userStr) } + } else { + log.Println("GetUserByIDFromUserCenter user not found, id:", id) + log.Println("response user:", user) } } - log.Println("user_str:", user_str) return user }