用户中心
This commit is contained in:
parent
8a55bfc82b
commit
4ecdda9468
|
|
@ -410,11 +410,12 @@ func GetUserByIDFromUserCenter(id int) dao.User {
|
||||||
var user dao.User
|
var user dao.User
|
||||||
//先从redis获取
|
//先从redis获取
|
||||||
key := "user_info_" + strconv.Itoa(id)
|
key := "user_info_" + strconv.Itoa(id)
|
||||||
user_str := worker.GetRedis(key)
|
userStr := worker.GetRedis(key)
|
||||||
if user_str != "" {
|
log.Println("user_str:", userStr)
|
||||||
err := json.Unmarshal([]byte(user_str), &user)
|
if userStr != "" {
|
||||||
|
err := json.Unmarshal([]byte(userStr), &user)
|
||||||
if err != nil {
|
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{}
|
return dao.User{}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -425,14 +426,16 @@ func GetUserByIDFromUserCenter(id int) dao.User {
|
||||||
fmt.Println("get user info , json marshal error:", err)
|
fmt.Println("get user info , json marshal error:", err)
|
||||||
return dao.User{}
|
return dao.User{}
|
||||||
}
|
}
|
||||||
user_str = string(userJson)
|
userStr = string(userJson)
|
||||||
success := worker.SetRedisWithExpire(key, user_str, time.Second*10)
|
success := worker.SetRedisWithExpire(key, userStr, time.Second*10)
|
||||||
if !success {
|
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
|
return user
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue