src/main/java/com/whyc/controller/UserController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/service/UserService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/whyc/controller/UserController.java
@@ -90,14 +90,25 @@ @GetMapping("validatePassword") @ApiOperation(value = "验证密码") public boolean validatePassword(@RequestParam String userName, @RequestParam String password){ return userService.validatePassword(userName,password); public boolean validatePassword(@RequestParam int id, @RequestParam String password){ return userService.validatePassword(id,password); } @GetMapping("getSaltPassword") @ApiOperation(value = "获取加密密码") public String getSaltPassword(@RequestParam String password,@RequestParam String salt){ return DigestsUtil.sha1(password,salt); } @PutMapping("updatePassword") @ApiOperation(value = "修改密码") public Response updatePassword(@RequestParam int id,@RequestParam String password){ return userService.updatePassword(id,password); } @PutMapping("resetPassword") @ApiOperation(value = "重置密码") public Response resetPassword(@RequestParam int id){ return userService.resetPassword(id); } @PutMapping src/main/java/com/whyc/service/UserService.java
@@ -98,12 +98,26 @@ } public boolean validatePassword(String userName, String password) { User user = userBridgeService.findPasswordAndSlatByUserName(userName); public boolean validatePassword(int id, String password) { User user = userMapper.selectById(id); boolean result = user.getPassword().equals(DigestsUtil.sha1(password, user.getSalt())); return result; } public Response updatePassword(int id,String password){ User user = userMapper.selectById(id); String saltPassword = DigestsUtil.sha1(password,user.getSalt()); user.setPassword(saltPassword); if (userMapper.updateById(user) > 0) { return new Response().setMsg(1, "修改成功"); } else { return new Response().setMsg(0, "修改失败"); } } public Response resetPassword(int id){ return updatePassword(id,"123456"); } public Response update(User user) { if (userMapper.updateById(user) > 0) { return new Response().setMsg(1, "更新成功");