| | |
| | | import com.zy.asrs.wcs.common.domain.BaseParam; |
| | | import com.zy.asrs.wcs.common.domain.KeyValVo; |
| | | import com.zy.asrs.wcs.common.domain.PageParam; |
| | | import com.zy.asrs.wcs.system.controller.param.ResetPwdParam; |
| | | import com.zy.asrs.wcs.system.entity.User; |
| | | import com.zy.asrs.wcs.system.entity.UserRole; |
| | | import com.zy.asrs.wcs.system.service.UserRoleService; |
| | |
| | | throw new CoolException("服务器内部错误"); |
| | | } |
| | | |
| | | userRoleService.remove(new LambdaQueryWrapper<UserRole>().eq(UserRole::getUserId, user.getId())); |
| | | for (Long roleId : user.getRoleIds()) { |
| | | if (!userRoleService.save(new UserRole(user.getId(), roleId))) { |
| | | throw new CoolException("服务器内部错误"); |
| | | if (user.getRoleIds() != null && user.getRoleIds().length > 0) { |
| | | userRoleService.remove(new LambdaQueryWrapper<UserRole>().eq(UserRole::getUserId, user.getId())); |
| | | for (Long roleId : user.getRoleIds()) { |
| | | if (!userRoleService.save(new UserRole(user.getId(), roleId))) { |
| | | throw new CoolException("服务器内部错误"); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | @PreAuthorize("hasAuthority('system:user:update')") |
| | | @OperationLog("重置密码") |
| | | @PostMapping("/user/reset/pwd") |
| | | public R resetPwd(@RequestBody User user) { |
| | | if (!Cools.isEmpty(user.getPassword())) { |
| | | user.setPassword(userService.encodePassword(user.getPassword())); |
| | | public R resetPwd(@RequestBody ResetPwdParam param) { |
| | | User user = userService.getById(param.getId()); |
| | | if (!Cools.isEmpty(param.getOldPwd())) { |
| | | if (!userService.comparePassword(user.getPassword(), param.getOldPwd())) { |
| | | return R.error("当前密码错误"); |
| | | } |
| | | } |
| | | if (!Cools.isEmpty(param.getPassword())) { |
| | | user.setPassword(userService.encodePassword(param.getPassword())); |
| | | } |
| | | user.setUpdateBy(getLoginUserId()); |
| | | user.setUpdateTime(new Date()); |