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())
}
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)