From fb2bcd87eb1882f5bc8fd5956e34dc3d727c2b5b Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Fri, 24 Nov 2023 11:18:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../internal/logic/usergetprofilelogic.go | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/server/info/internal/logic/usergetprofilelogic.go b/server/info/internal/logic/usergetprofilelogic.go index be80d866..dcdfd063 100644 --- a/server/info/internal/logic/usergetprofilelogic.go +++ b/server/info/internal/logic/usergetprofilelogic.go @@ -39,14 +39,19 @@ func (l *UserGetProfileLogic) UserGetProfile(req *types.QueryProfileRequest, use return resp.SetStatusWithMessage(basic.CodeApiErr, err.Error()) } - user, err := l.svcCtx.AllModels.FsUser.FindUserById(context.TODO(), userinfo.UserId) - if err != nil { - logx.Error(err) // 日志记录错误 - return resp.SetStatus(basic.CodeDbSqlErr, err) // 返回数据库创建错误 - } - - if bmap, ok := profileBase["base"].(map[string]any); ok { - bmap["email"] = *user.Email + if userinfo.UserId != 0 { + user, err := l.svcCtx.AllModels.FsUser.FindUserById(context.TODO(), userinfo.UserId) + if err != nil { + logx.Error(err) // 日志记录错误 + return resp.SetStatus(basic.CodeDbSqlErr, err) // 返回数据库创建错误 + } + if bmap, ok := profileBase["base"].(map[string]any); ok { + bmap["email"] = *user.Email + } + } else { + if bmap, ok := profileBase["base"].(map[string]any); ok { + bmap["email"] = "" + } } return resp.SetStatus(basic.CodeOK, profileBase)