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);