| | |
| | | private ISysPermissionService permissionService; |
| | | @Resource |
| | | private ISysUserDeptService sysUserDeptService; |
| | | |
| | | |
| | | @PostMapping("/removeByAppUserId/{id}") |
| | | public AjaxResult removeByAppUserId(@PathVariable("id") Long id) |
| | | { |
| | | SysUser byId = userService.getById(id); |
| | | userService.removeById(byId); |
| | | return AjaxResult.success(); |
| | | } |
| | | /** |
| | | * 获取用户列表 |
| | | */ |
| | |
| | | for (SysUserVO record : list.getRecords()) { |
| | | List<Long> collect1 = sysUserRoleService.lambdaQuery().eq(SysUserRole::getUserId, record.getUserId()) |
| | | .list().stream().map(SysUserRole::getRoleId).collect(Collectors.toList()); |
| | | record.setRole(collect1); |
| | | List<Long> longs1 = new ArrayList<>(); |
| | | for (Long l : collect1) { |
| | | SysRole sysDept = roleService.selectRoleById(l); |
| | | if (sysDept!=null){ |
| | | longs1.add(sysDept.getRoleId()); |
| | | } |
| | | } |
| | | record.setRole(longs1); |
| | | List<String> strings1 = new ArrayList<>(); |
| | | if (record.getRole()!=null && (!record.getRole().isEmpty())){ |
| | | for (Long l : collect1) { |
| | |
| | | record.setRoleNames(strings1); |
| | | List<Long> collect2 = sysUserDeptService.lambdaQuery().eq(SysUserDept::getUserId, record.getUserId()) |
| | | .list().stream().map(SysUserDept::getDeptId).collect(Collectors.toList()); |
| | | record.setDeptIds(collect2); |
| | | List<Long> longs2 = new ArrayList<>(); |
| | | for (Long l : collect2) { |
| | | SysDept sysDept = deptService.selectDeptById(l); |
| | | if (sysDept!=null){ |
| | | longs2.add(sysDept.getDeptId()); |
| | | } |
| | | } |
| | | record.setDeptIds(longs2); |
| | | List<String> strings = new ArrayList<>(); |
| | | if (record.getDeptIds()!=null && (!record.getDeptIds().isEmpty())){ |
| | | for (Long deptId : record.getDeptIds()) { |
| | |
| | | user.setUpdateTime(LocalDateTime.now()); |
| | | if (user.getPassword()!=null){ |
| | | user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | | |
| | | return AjaxResult.success(userService.resetPwd(user)); |
| | | } |
| | | |
| | | return AjaxResult.success(userService.updateUser(user)); |
| | |
| | | user.setUserId(dto.getUserId()); |
| | | user.setStatus(String.valueOf(dto.getStatus())); |
| | | user.setReason(dto.getReason()); |
| | | user.setDisableTime(LocalDateTime.now()); |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = userService.selectUserById(userid); |
| | | user.setUpdateBy(sysUser.getNickName()+"("+sysUser.getUserName()+")"); |
| | |
| | | @PostMapping("/app-register") |
| | | public R<SysUser> appRegister(@RequestBody SysUser sysUser) { |
| | | String username = sysUser.getUserName(); |
| | | if (!userService.checkAppUserNameUnique(sysUser)) { |
| | | return R.fail("保存用户'" + username + "'失败,注册账号已存在"); |
| | | } |
| | | |
| | | //添加用户 |
| | | userService.registerUser(sysUser); |
| | | return R.ok(sysUser); |
| | |
| | | /** |
| | | * 重置密码 |
| | | */ |
| | | @RequiresPermissions("system:user:edit") |
| | | @Log(title = "用户管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/resetPwd") |
| | | @PostMapping("/resetPwd") |
| | | public AjaxResult resetPwd(@RequestBody SysUser user) { |
| | | userService.checkUserAllowed(user); |
| | | userService.checkUserDataScope(user.getUserId()); |
| | | user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | | user.setUpdateBy(SecurityUtils.getUsername()); |
| | | return toAjax(userService.resetPwd(user)); |