| | |
| | | |
| | | User u = securityUtil.getCurrUser(); |
| | | // 清除持久上下文环境 避免后面语句导致持久化 |
| | | entityManager.clear(); |
| | | u.setPassword(null); |
| | | // entityManager.clear(); |
| | | // u.setPassword(null); |
| | | return new ResultUtil<User>().setData(u); |
| | | } |
| | | |
| | |
| | | |
| | | User user = securityUtil.getCurrUser(); |
| | | // 在线DEMO所需 |
| | | if ("test".equals(user.getUsername()) || "test2".equals(user.getUsername())) { |
| | | return ResultUtil.error("演示账号不支持修改密码"); |
| | | } |
| | | // if (user.getType()==0) { |
| | | // return ResultUtil.error("业务账号不支持修改密码"); |
| | | // } |
| | | |
| | | if (!new BCryptPasswordEncoder().matches(password, user.getPassword())) { |
| | | return ResultUtil.error("旧密码不正确"); |
| | |
| | | |
| | | String newEncryptPass = new BCryptPasswordEncoder().encode(newPass); |
| | | user.setPassword(newEncryptPass); |
| | | if(StrUtil.isEmpty(passStrength)){ |
| | | passStrength="强"; |
| | | } |
| | | user.setPassStrength(passStrength); |
| | | user.setDescription(newPass); |
| | | userService.update(user); |
| | | |
| | | // 手动更新缓存 |
| | | redisTemplate.delete(USER + user.getUsername()); |
| | | //redisTemplate.delete(USER + user.getUsername()); |
| | | |
| | | return ResultUtil.success("修改密码成功"); |
| | | } |
| | |
| | | public Result<List<User>> getByCondition(@PathVariable String departmentId) { |
| | | |
| | | List<User> list = userService.findByDepartmentId(departmentId); |
| | | entityManager.clear(); |
| | | list.forEach(u -> { |
| | | u.setPassword(null); |
| | | }); |
| | | // entityManager.clear(); |
| | | // list.forEach(u -> { |
| | | // u.setPassword(null); |
| | | // }); |
| | | return new ResultUtil<List<User>>().setData(list); |
| | | } |
| | | |
| | |
| | | public Result<List<User>> searchByName(@PathVariable String username) throws UnsupportedEncodingException { |
| | | |
| | | List<User> list = userService.findByUsernameLikeAndStatus(URLDecoder.decode(username, "utf-8"), CommonConstant.STATUS_NORMAL); |
| | | entityManager.clear(); |
| | | list.forEach(u -> { |
| | | u.setPassword(null); |
| | | }); |
| | | // entityManager.clear(); |
| | | // list.forEach(u -> { |
| | | // u.setPassword(null); |
| | | // }); |
| | | return new ResultUtil<List<User>>().setData(list); |
| | | } |
| | | |
| | |
| | | |
| | | List<User> list = userService.getAll(); |
| | | // 清除持久上下文环境 避免后面语句导致持久化 |
| | | entityManager.clear(); |
| | | for (User u : list) { |
| | | u.setPassword(null); |
| | | } |
| | | // entityManager.clear(); |
| | | // for (User u : list) { |
| | | // u.setPassword(null); |
| | | // } |
| | | return new ResultUtil<List<User>>().setData(list); |
| | | } |
| | | |
| | |
| | | if (!old.getMobile().equals(u.getMobile()) && userService.findByMobile(u.getMobile()) != null) { |
| | | return ResultUtil.error("该手机号已绑定其他账户"); |
| | | } |
| | | if (!old.getEmail().equals(u.getEmail()) && userService.findByEmail(u.getEmail()) != null) { |
| | | return ResultUtil.error("该邮箱已绑定其他账户"); |
| | | } |
| | | // if (!old.getEmail().equals(u.getEmail()) && userService.findByEmail(u.getEmail()) != null) { |
| | | // return ResultUtil.error("该邮箱已绑定其他账户"); |
| | | // } |
| | | |
| | | if (StrUtil.isNotBlank(u.getDepartmentId())) { |
| | | Department d = departmentService.get(u.getDepartmentId()); |
| | |
| | | if (StrUtil.isNotBlank(username) && userService.findByUsername(username) != null) { |
| | | throw new XbootException("该登录账号已被注册"); |
| | | } |
| | | if (StrUtil.isNotBlank(email) && userService.findByEmail(email) != null) { |
| | | throw new XbootException("该邮箱已被注册"); |
| | | } |
| | | // if (StrUtil.isNotBlank(email) && userService.findByEmail(email) != null) { |
| | | // throw new XbootException("该邮箱已被注册"); |
| | | // } |
| | | if (StrUtil.isNotBlank(mobile) && userService.findByMobile(mobile) != null) { |
| | | throw new XbootException("该手机号已被注册"); |
| | | } |
| | |
| | | |
| | | List<User> list = userService.findByType2(type); |
| | | // 清除持久上下文环境 避免后面语句导致持久化 |
| | | entityManager.clear(); |
| | | List<User> list1 = new ArrayList<User>(); |
| | | //entityManager.clear(); |
| | | for (User u : list) { |
| | | u.setPassword(null); |
| | | //u.setPassword(null); |
| | | if (u.getType()==0){ |
| | | list1.add(u); |
| | | } |
| | | } |
| | | return new ResultUtil<List<User>>().setData(list); |
| | | return new ResultUtil<List<User>>().setData(list1); |
| | | } |
| | | } |