修改用户个人资料同步缓存信息

This commit is contained in:
RuoYi 2020-02-08 16:39:13 +08:00
parent d49ac2e0f8
commit 5cdb4ecba5

View File

@ -59,7 +59,18 @@ public class SysProfileController extends BaseController
@PutMapping
public AjaxResult updateProfile(@RequestBody SysUser user)
{
return toAjax(userService.updateUserProfile(user));
if (userService.updateUserProfile(user) > 0)
{
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
// 更新缓存用户信息
loginUser.getUser().setNickName(user.getNickName());
loginUser.getUser().setPhonenumber(user.getPhonenumber());
loginUser.getUser().setEmail(user.getEmail());
loginUser.getUser().setSex(user.getSex());
tokenService.setLoginUser(loginUser);
return AjaxResult.success();
}
return AjaxResult.error("修改个人信息异常,请联系管理员");
}
/**
@ -98,6 +109,7 @@ public class SysProfileController extends BaseController
{
AjaxResult ajax = AjaxResult.success();
ajax.put("imgUrl", avatar);
// 更新缓存用户头像
loginUser.getUser().setAvatar(avatar);
tokenService.setLoginUser(loginUser);
return ajax;