1. 新增业务数据查询,新增 部门 数据权限规则支持
2. 补全子角色排除父角色管理菜单测试用例
This commit is contained in:
@@ -383,4 +383,29 @@ public class PermissionServiceTest extends BaseDbUnitTest {
|
||||
assertTrue(menuIds2.contains(101L));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 测试子角色排除父角色菜单
|
||||
* 通过 Service 方法排除,确保子角色不继承父角色的菜单
|
||||
*/
|
||||
@Test
|
||||
public void testExcludeParentRoleMenu() {
|
||||
// mock 父子关系 A->B
|
||||
RoleDO parentRole = randomPojo(RoleDO.class, o -> o.setParentId(0L));
|
||||
roleMapper.insert(parentRole);
|
||||
RoleDO childRole = randomPojo(RoleDO.class, o -> o.setParentId(parentRole.getId()));
|
||||
roleMapper.insert(childRole);
|
||||
// 父角色分配菜单
|
||||
RoleMenuDO parentMenu = randomPojo(RoleMenuDO.class).setRoleId(parentRole.getId()).setMenuId(101L);
|
||||
roleMenuMapper.insert(parentMenu);
|
||||
// 子角色排除父菜单(通过 Service 方法排除)
|
||||
permissionService.assignRoleMenu(childRole.getId(), Collections.emptySet());
|
||||
// 调用:获取子角色菜单(应不包含父菜单)
|
||||
Set<Long> menuIds = permissionService.getRoleMenuListByRoleId(childRole.getId());
|
||||
assertFalse(menuIds.contains(101L));
|
||||
// 新增了子角色的排除菜单记录
|
||||
List<RoleMenuExclusionDO> exclusionDOS = roleMenuExclusionMapper.selectMenuIdListByRoleId(Collections.singleton(childRole.getId()));
|
||||
assertEquals(1, exclusionDOS.size());
|
||||
assertEquals(101L, exclusionDOS.get(0).getMenuId());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user