This commit is contained in:
eson 2023-11-24 11:18:17 +08:00
parent e164ced733
commit fb2bcd87eb

View File

@ -39,14 +39,19 @@ func (l *UserGetProfileLogic) UserGetProfile(req *types.QueryProfileRequest, use
return resp.SetStatusWithMessage(basic.CodeApiErr, err.Error()) return resp.SetStatusWithMessage(basic.CodeApiErr, err.Error())
} }
user, err := l.svcCtx.AllModels.FsUser.FindUserById(context.TODO(), userinfo.UserId) if userinfo.UserId != 0 {
if err != nil { user, err := l.svcCtx.AllModels.FsUser.FindUserById(context.TODO(), userinfo.UserId)
logx.Error(err) // 日志记录错误 if err != nil {
return resp.SetStatus(basic.CodeDbSqlErr, err) // 返回数据库创建错误 logx.Error(err) // 日志记录错误
} return resp.SetStatus(basic.CodeDbSqlErr, err) // 返回数据库创建错误
}
if bmap, ok := profileBase["base"].(map[string]any); ok { if bmap, ok := profileBase["base"].(map[string]any); ok {
bmap["email"] = *user.Email bmap["email"] = *user.Email
}
} else {
if bmap, ok := profileBase["base"].(map[string]any); ok {
bmap["email"] = ""
}
} }
return resp.SetStatus(basic.CodeOK, profileBase) return resp.SetStatus(basic.CodeOK, profileBase)