From cd735acee6bbde2f0656c221b334db4c43103554 Mon Sep 17 00:00:00 2001 From: hujiebin Date: Fri, 24 Mar 2023 18:08:10 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"fix=EF=BC=9A=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit b335e750b889044f9f1abb845c5aa0e80f5b8df2. --- req/request.go | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/req/request.go b/req/request.go index 6dcb235..39ae35f 100644 --- a/req/request.go +++ b/req/request.go @@ -7,7 +7,6 @@ import ( "github.com/gin-gonic/gin" "hilo-group/domain/cache/user_c" "hilo-group/domain/model/res_m" - "hilo-group/domain/model/user_m" "hilo-group/myerr" "hilo-group/myerr/bizerr" "strconv" @@ -89,11 +88,25 @@ 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) { if userIdStr, ok := c.Keys[mycontext.USERID]; ok { userId := userIdStr.(uint64) - user, err := user_m.GetUser(domain.CreateModelContext(myContext), userId) - if err != nil { - return 0, "", "", "", "", bizerr.ExternalIdNoExist + + externalId, ok1 := c.Get(mycontext.EXTERNAL_ID) + nick, ok2 := c.Get(mycontext.NICK) + 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 } -- 2.22.0