From 146c268dff91432c368d610e7fdea9a3a75fdba8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=B6Stone?= <244251889@qq.com> Date: Wed, 30 Aug 2023 13:35:57 +0000 Subject: [PATCH] =?UTF-8?q?!416=20fix=20=E4=BF=AE=E5=A4=8D=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E4=BC=9A=E5=AD=98=E5=9C=A8=E7=9A=84=E8=B6=8A=E6=9D=83?= =?UTF-8?q?=E8=A1=8C=E4=B8=BA=20*=20fix=20=E4=BF=AE=E5=A4=8D=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E4=BC=9A=E5=AD=98=E5=9C=A8=E7=9A=84=E8=B6=8A=E6=9D=83?= =?UTF-8?q?=E8=A1=8C=E4=B8=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/service/ISysUserService.java | 7 ++++++ .../service/impl/SysUserServiceImpl.java | 22 +++++++++++++++++++ 2 files changed, 29 insertions(+) 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 bbe78be2..392aea06 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,6 +119,13 @@ 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 0a13a500..19db097d 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 @@ -27,6 +27,7 @@ import org.dromara.system.domain.SysUser; import org.dromara.system.domain.SysUserPost; import org.dromara.system.domain.SysUserRole; import org.dromara.system.domain.bo.SysUserBo; +import org.dromara.system.domain.vo.SysDeptVo; import org.dromara.system.domain.vo.SysPostVo; import org.dromara.system.domain.vo.SysRoleVo; import org.dromara.system.domain.vo.SysUserVo; @@ -264,6 +265,25 @@ 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("没有权限访问部门数据!"); + } + } + /** * 新增保存用户信息 * @@ -273,6 +293,7 @@ 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); @@ -308,6 +329,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService { @Override @Transactional(rollbackFor = Exception.class) public int updateUser(SysUserBo user) { + this.checkDeptDataScope(user.getDeptId()); // 新增用户与角色管理 insertUserRole(user, true); // 新增用户与岗位管理