diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysUserController.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysUserController.java index 9dafb9cb..fdefe422 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysUserController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysUserController.java @@ -151,6 +151,7 @@ public class SysUserController extends BaseController { @Log(title = "用户管理", businessType = BusinessType.INSERT) @PostMapping public R add(@Validated @RequestBody SysUserBo user) { + deptService.checkDeptDataScope(user.getDeptId()); if (!userService.checkUserNameUnique(user)) { return R.fail("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); } else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) { @@ -176,6 +177,7 @@ public class SysUserController extends BaseController { public R edit(@Validated @RequestBody SysUserBo user) { userService.checkUserAllowed(user.getUserId()); userService.checkUserDataScope(user.getUserId()); + deptService.checkDeptDataScope(user.getDeptId()); if (!userService.checkUserNameUnique(user)) { return R.fail("修改用户'" + user.getUserName() + "'失败,登录账号已存在"); } else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) { diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/ISysUserService.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/ISysUserService.java index 392aea06..bbe78be2 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/ISysUserService.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/ISysUserService.java @@ -119,13 +119,6 @@ public interface ISysUserService { */ void checkUserDataScope(Long userId); - /** - * 校验部门是否有数据权限 - * - * @param deptId 部门id - */ - void checkDeptDataScope(Long deptId); - /** * 新增用户信息 * diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysUserServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysUserServiceImpl.java index 19db097d..068f5239 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysUserServiceImpl.java @@ -265,25 +265,6 @@ public class SysUserServiceImpl implements ISysUserService, UserService { } } - /** - * 校验部门是否有数据权限 - * - * @param deptId 部门id - */ - @Override - public void checkDeptDataScope(Long deptId) { - if (ObjectUtil.isNull(deptId)) { - return; - } - if (LoginHelper.isSuperAdmin()) { - return; - } - SysDeptVo dept = deptMapper.selectDeptById(deptId); - if (ObjectUtil.isNull(dept)) { - throw new ServiceException("没有权限访问部门数据!"); - } - } - /** * 新增保存用户信息 * @@ -293,7 +274,6 @@ public class SysUserServiceImpl implements ISysUserService, UserService { @Override @Transactional(rollbackFor = Exception.class) public int insertUser(SysUserBo user) { - this.checkDeptDataScope(user.getDeptId()); SysUser sysUser = MapstructUtils.convert(user, SysUser.class); // 新增用户信息 int rows = baseMapper.insert(sysUser); @@ -329,7 +309,6 @@ public class SysUserServiceImpl implements ISysUserService, UserService { @Override @Transactional(rollbackFor = Exception.class) public int updateUser(SysUserBo user) { - this.checkDeptDataScope(user.getDeptId()); // 新增用户与角色管理 insertUserRole(user, true); // 新增用户与岗位管理