From 7cf571adc133a176bf52e20211ac11d98e40eb90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Thu, 14 Jun 2018 16:05:49 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=20BUG.=20fix=20#IKIJ4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pig/admin/controller/UserController.java | 2 +- .../github/pig/admin/model/entity/SysUser.java | 1 - .../github/pig/admin/service/SysUserService.java | 2 +- .../admin/service/impl/SysUserServiceImpl.java | 16 +++++++++++----- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/controller/UserController.java b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/controller/UserController.java index d8961d09..1926ae51 100644 --- a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/controller/UserController.java +++ b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/controller/UserController.java @@ -209,6 +209,6 @@ public class UserController extends BaseController { */ @PutMapping("/editInfo") public R editInfo(@RequestBody UserDTO userDto, UserVO userVo) { - return new R<>(userService.updateUserInfo(userDto, userVo.getUsername())); + return userService.updateUserInfo(userDto, userVo.getUsername()); } } diff --git a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/model/entity/SysUser.java b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/model/entity/SysUser.java index e9e1b8a0..bc2854c4 100644 --- a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/model/entity/SysUser.java +++ b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/model/entity/SysUser.java @@ -52,7 +52,6 @@ public class SysUser extends Model { */ private String username; - @JsonIgnore private String password; /** * 随机盐 diff --git a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/SysUserService.java b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/SysUserService.java index 6c94077c..3fce0d0c 100644 --- a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/SysUserService.java +++ b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/SysUserService.java @@ -75,7 +75,7 @@ public interface SysUserService extends IService { * @param username 用户名 * @return Boolean */ - Boolean updateUserInfo(UserDTO userDto, String username); + R updateUserInfo(UserDTO userDto, String username); /** * 更新指定用户信息 diff --git a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/impl/SysUserServiceImpl.java b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/impl/SysUserServiceImpl.java index 44772540..032efab7 100644 --- a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/impl/SysUserServiceImpl.java +++ b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/impl/SysUserServiceImpl.java @@ -245,16 +245,22 @@ public class SysUserServiceImpl extends ServiceImpl impl @Override @CacheEvict(value = "user_details", key = "#username") - public Boolean updateUserInfo(UserDTO userDto, String username) { + public R updateUserInfo(UserDTO userDto, String username) { UserVO userVo = this.findUserByUsername(username); - SysUser sysUser = new SysUser(); - if (ENCODER.matches(userDto.getPassword(), userVo.getPassword())) { - sysUser.setPassword(ENCODER.encode(userDto.getNewpassword1())); + if (StrUtil.isNotBlank(userDto.getPassword()) + && StrUtil.isNotBlank(userDto.getNewpassword1())) { + if (ENCODER.matches(userDto.getPassword(), userVo.getPassword())) { + sysUser.setPassword(ENCODER.encode(userDto.getNewpassword1())); + } else { + log.warn("原密码错误,修改密码失败:{}", username); + return new R<>(Boolean.FALSE, "原密码错误,修改失败"); + } } + sysUser.setPhone(userDto.getPhone()); sysUser.setUserId(userVo.getUserId()); sysUser.setAvatar(userDto.getAvatar()); - return this.updateById(sysUser); + return new R<>(this.updateById(sysUser)); } @Override