From 5cdb4ecba56abd729f710bf468b5ab7d0f922e2d Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sat, 8 Feb 2020 16:39:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7=E4=B8=AA?= =?UTF-8?q?=E4=BA=BA=E8=B5=84=E6=96=99=E5=90=8C=E6=AD=A5=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/controller/SysProfileController.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysProfileController.java b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysProfileController.java index aab393635..176a9a17f 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysProfileController.java +++ b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysProfileController.java @@ -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;