| | |
| | | } |
| | | |
| | | |
| | | 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, "更新成功"); |