| | |
| | | private ISysPermissionService permissionService; |
| | | |
| | | @Resource |
| | | private PartnerTypeRoleService partnerTypeRoleService; |
| | | |
| | | @Resource |
| | | private ISysConfigService configService; |
| | | |
| | | @Resource |
| | |
| | | if (StringUtils.isNull(sysUser)) { |
| | | return R.fail("用户名/密码错误"); |
| | | } |
| | | sysUser = synchronizePartnerTypeRole(sysUser); |
| | | // 角色集合 |
| | | Set<String> roles = permissionService.getRolePermission(sysUser); |
| | | // 权限集合 |
| | |
| | | @GetMapping("/getInfo") |
| | | public AjaxResult getInfo() { |
| | | SysUser user = userService.selectUserById(tokenService.getLoginUser().getUserid()); |
| | | user = synchronizePartnerTypeRole(user); |
| | | // 角色集合 |
| | | Set<String> roles = permissionService.getRolePermission(user); |
| | | // 权限集合 |
| | |
| | | ajax.put("roles", roles); |
| | | ajax.put("permissions", permissions); |
| | | return ajax; |
| | | } |
| | | |
| | | private SysUser synchronizePartnerTypeRole(SysUser user) { |
| | | partnerTypeRoleService.synchronize(user); |
| | | if (user != null && Integer.valueOf(2).equals(user.getRoleType()) && user.getObjectId() != null) { |
| | | return userService.selectUserById(user.getUserId()); |
| | | } |
| | | return user; |
| | | } |
| | | |
| | | |
| | |
| | | @ApiOperation(value = "重置操作密码", tags = {"管理后台-系统用户管理"}) |
| | | public AjaxResult resetOperationPwd(@RequestBody Map<String, Object> params) { |
| | | Long userId = parseLong(params.get("userId")); |
| | | String operationPassword = parseString(params.get("operationPassword")); |
| | | String code = parseString(params.get("code")); |
| | | if (userId == null) { |
| | | return AjaxResult.error("用户不存在"); |
| | | } |
| | | if (StringUtils.isEmpty(operationPassword)) { |
| | | return AjaxResult.error("请输入新操作密码"); |
| | | } |
| | | if (StringUtils.isEmpty(code)) { |
| | | return AjaxResult.error("请输入验证码"); |
| | | } |
| | | |
| | | SysUser user = userService.selectUserById(userId); |
| | |
| | | userService.checkUserAllowed(user); |
| | | userService.checkUserDataScope(userId); |
| | | |
| | | user.setOperationPassword(SecurityUtils.encryptPassword("123456")); |
| | | String cacheCode = redisService.getCacheObject(RESET_PWD_CODE_KEY + userId); |
| | | if (StringUtils.isEmpty(cacheCode)) { |
| | | return AjaxResult.error("验证码已过期,请重新获取验证码"); |
| | | } |
| | | if (!code.equals(cacheCode)) { |
| | | return AjaxResult.error("验证码错误"); |
| | | } |
| | | |
| | | user.setOperationPassword(SecurityUtils.encryptPassword(operationPassword)); |
| | | user.setUpdateBy(SecurityUtils.getUsername()); |
| | | return toAjax(userService.updateUser(user)); |
| | | int result = userService.updateUser(user); |
| | | redisService.deleteObject(RESET_PWD_CODE_KEY + userId); |
| | | return toAjax(result); |
| | | } |
| | | private Long parseLong(Object value) { |
| | | if (value == null || StringUtils.isEmpty(String.valueOf(value))) { |