Commit b335e750 authored by hujiebin's avatar hujiebin

fix:修复获取用户信息的问题

parent b02af66d
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"hilo-group/domain/cache/user_c" "hilo-group/domain/cache/user_c"
"hilo-group/domain/model/res_m" "hilo-group/domain/model/res_m"
"hilo-group/domain/model/user_m"
"hilo-group/myerr" "hilo-group/myerr"
"hilo-group/myerr/bizerr" "hilo-group/myerr/bizerr"
"strconv" "strconv"
...@@ -88,25 +89,11 @@ func GetUserIdLang(c *gin.Context, myContext *mycontext.MyContext) (mysql.ID, st ...@@ -88,25 +89,11 @@ func GetUserIdLang(c *gin.Context, myContext *mycontext.MyContext) (mysql.ID, st
func GetUserEx(c *gin.Context, myContext *mycontext.MyContext) (mysql.ID, string, string, string, string, error) { func GetUserEx(c *gin.Context, myContext *mycontext.MyContext) (mysql.ID, string, string, string, string, error) {
if userIdStr, ok := c.Keys[mycontext.USERID]; ok { if userIdStr, ok := c.Keys[mycontext.USERID]; ok {
userId := userIdStr.(uint64) userId := userIdStr.(uint64)
user, err := user_m.GetUser(domain.CreateModelContext(myContext), userId)
externalId, ok1 := c.Get(mycontext.EXTERNAL_ID) if err != nil {
nick, ok2 := c.Get(mycontext.NICK) return 0, "", "", "", "", bizerr.ExternalIdNoExist
avatar, ok3 := c.Get(mycontext.AVATAR)
country, ok4 := c.Get(mycontext.COUNTRY)
ok := ok1 && ok2 && ok3 && ok4
if ok {
return userId, externalId.(string), nick.(string), avatar.(string), country.(string), nil
} else {
//var user user_m.User
//if err := mysql.Db.First(&user, userId).Error; err != nil {
// return 0, "", "", "", "", bizerr.ExternalIdNoExist
//}
user, err := user_c.GetUserTinyById(domain.CreateModelContext(myContext), userId)
if err != nil {
return 0, "", "", "", "", bizerr.ExternalIdNoExist
}
return userId, user.ExternalId, user.Nick, user.Avatar, user.Country, nil
} }
return userId, user.ExternalId, user.Nick, user.Avatar, user.Country, nil
} }
return 0, "", "", "", "", bizerr.ParaMissing return 0, "", "", "", "", bizerr.ParaMissing
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment