mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	update 优化 部门与角色如果绑定了用户则不允许禁用
This commit is contained in:
		@@ -91,9 +91,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));
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -268,6 +268,9 @@ public class SysRoleServiceImpl implements ISysRoleService {
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public int updateRoleStatus(SysRole role) {
 | 
			
		||||
        if (UserConstants.ROLE_DISABLE.equals(role.getStatus()) && this.countUserRoleByRoleId(role.getRoleId()) > 0) {
 | 
			
		||||
            throw new ServiceException("角色已分配,不能禁用!");
 | 
			
		||||
        }
 | 
			
		||||
        return baseMapper.updateById(role);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -360,7 +363,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
 | 
			
		||||
            checkRoleAllowed(role);
 | 
			
		||||
            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<Long> ids = Arrays.asList(roleIds);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user