From 1d517316ea5be682fb4a6d5b5a1fa102f2595a00 Mon Sep 17 00:00:00 2001 From: Elune <201507802@qq.com> Date: Thu, 11 Jul 2019 14:25:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=86=E7=A0=81=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/system/domain/vo/UserPassVo.java | 16 ++++++++++++++++ .../modules/system/rest/UserController.java | 9 +++++---- 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/system/domain/vo/UserPassVo.java diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/vo/UserPassVo.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/vo/UserPassVo.java new file mode 100644 index 00000000..86288673 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/vo/UserPassVo.java @@ -0,0 +1,16 @@ +package me.zhengjie.modules.system.domain.vo; + +import lombok.Data; + +/** + * 修改密码的 Vo 类 + * @author Zheng Jie + * @date 2019年7月11日13:59:49 + */ +@Data +public class UserPassVo { + + private String oldPass; + + private String newPass; +} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java index 37313d04..3e53fa4f 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java @@ -6,6 +6,7 @@ import me.zhengjie.domain.Picture; import me.zhengjie.domain.VerificationCode; import me.zhengjie.modules.system.domain.User; import me.zhengjie.exception.BadRequestException; +import me.zhengjie.modules.system.domain.vo.UserPassVo; import me.zhengjie.modules.system.service.DeptService; import me.zhengjie.modules.system.service.RoleService; import me.zhengjie.modules.system.service.dto.RoleSmallDTO; @@ -127,15 +128,15 @@ public class UserController { * @return */ @PostMapping(value = "/users/updatePass") - public ResponseEntity updatePass(@RequestBody User user){ + public ResponseEntity updatePass(@RequestBody UserPassVo user){ UserDetails userDetails = SecurityUtils.getUserDetails(); - if(!userDetails.getPassword().equals(EncryptUtils.encryptPassword(user.getPassword()))){ + if(!userDetails.getPassword().equals(EncryptUtils.encryptPassword(user.getOldPass()))){ throw new BadRequestException("修改失败,旧密码错误"); } - if(userDetails.getPassword().equals(EncryptUtils.encryptPassword(user.getPassword()))){ + if(userDetails.getPassword().equals(EncryptUtils.encryptPassword(user.getNewPass()))){ throw new BadRequestException("新密码不能与旧密码相同"); } - userService.updatePass(userDetails.getUsername(),EncryptUtils.encryptPassword(user.getPassword())); + userService.updatePass(userDetails.getUsername(),EncryptUtils.encryptPassword(user.getNewPass())); return new ResponseEntity(HttpStatus.OK); }