From afdc4b103d76b3335ced088e66ab42569003969e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Mon, 7 Aug 2023 17:41:11 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=20=E9=83=A8?= =?UTF-8?q?=E9=97=A8=E4=B8=8E=E8=A7=92=E8=89=B2=E5=A6=82=E6=9E=9C=E7=BB=91?= =?UTF-8?q?=E5=AE=9A=E4=BA=86=E7=94=A8=E6=88=B7=E5=88=99=E4=B8=8D=E5=85=81?= =?UTF-8?q?=E8=AE=B8=E7=A6=81=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/controller/system/SysDeptController.java | 9 ++++++--- .../dromara/system/service/impl/SysRoleServiceImpl.java | 5 ++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysDeptController.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysDeptController.java index 478ac6e9..130c0d1f 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysDeptController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysDeptController.java @@ -92,9 +92,12 @@ public class SysDeptController extends BaseController { return R.fail("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在"); } else if (dept.getParentId().equals(deptId)) { return R.fail("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); - } else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) - && deptService.selectNormalChildrenDeptById(deptId) > 0) { - return R.fail("该部门包含未停用的子部门!"); + } else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())) { + if (deptService.selectNormalChildrenDeptById(deptId) > 0) { + return R.fail("该部门包含未停用的子部门!"); + } else if (deptService.checkDeptExistUser(deptId)) { + return R.fail("该部门下存在已分配用户,不能禁用!"); + } } return toAjax(deptService.updateDept(dept)); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysRoleServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysRoleServiceImpl.java index 7b8e8f9b..79fada23 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysRoleServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysRoleServiceImpl.java @@ -283,6 +283,9 @@ public class SysRoleServiceImpl implements ISysRoleService { */ @Override public int updateRoleStatus(Long roleId, String status) { + if (UserConstants.ROLE_DISABLE.equals(status) && this.countUserRoleByRoleId(roleId) > 0) { + throw new ServiceException("角色已分配,不能禁用!"); + } return baseMapper.update(null, new LambdaUpdateWrapper() .set(SysRole::getStatus, status) @@ -379,7 +382,7 @@ public class SysRoleServiceImpl implements ISysRoleService { checkRoleAllowed(BeanUtil.toBean(role, SysRoleBo.class)); checkRoleDataScope(roleId); if (countUserRoleByRoleId(roleId) > 0) { - throw new ServiceException(String.format("%1$s已分配,不能删除", role.getRoleName())); + throw new ServiceException(String.format("%1$s已分配,不能删除!", role.getRoleName())); } } List ids = Arrays.asList(roleIds);