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)