|
@@ -87,11 +87,23 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public boolean grant(@NotEmpty List<Long> roleIds, List<String> menuIds, List<String> menuClientIds, List<Long> dataScopeIds, List<Long> apiScopeIds, List<Long> tableOwners, List<String> menuArchivesIds, List<String> menuHacIds, List<String> menuLarIds) {
|
|
|
- return grantRoleMenu(roleIds, menuIds, menuClientIds, menuArchivesIds, menuHacIds, menuLarIds) && grantDataScope(roleIds, dataScopeIds) && grantApiScope(roleIds, apiScopeIds) && submitRoleAndTableOwner(roleIds, tableOwners);
|
|
|
+ public boolean grant(@NotEmpty List<Long> roleIds, List<String> menuIds, List<String> menuClientIds
|
|
|
+ , List<Long> dataScopeIds, List<Long> apiScopeIds
|
|
|
+ , List<Long> tableOwners, List<String> menuArchivesIds
|
|
|
+ , List<String> menuHacIds, List<String> menuLarIds
|
|
|
+ , List<String> menuMeasureIds, List<String> menuSecureIds) {
|
|
|
+
|
|
|
+ return grantRoleMenu(roleIds, menuIds, menuClientIds, menuArchivesIds, menuHacIds, menuLarIds, menuMeasureIds, menuSecureIds)
|
|
|
+ && grantDataScope(roleIds, dataScopeIds)
|
|
|
+ && grantApiScope(roleIds, apiScopeIds)
|
|
|
+ && submitRoleAndTableOwner(roleIds, tableOwners);
|
|
|
}
|
|
|
|
|
|
- private boolean grantRoleMenu(List<Long> roleIds, List<String> menuIds, List<String> menuClientIds, List<String> menuArchivesIds, List<String> menuHacIds, List<String> menuLarIds) {
|
|
|
+ private boolean grantRoleMenu(List<Long> roleIds
|
|
|
+ , List<String> menuIds, List<String> menuClientIds, List<String> menuArchivesIds
|
|
|
+ , List<String> menuHacIds, List<String> menuLarIds
|
|
|
+ , List<String> menuMeasureIds, List<String> menuSecureIds
|
|
|
+ ) {
|
|
|
// 防止越权配置超管角色
|
|
|
Long administratorCount = baseMapper.selectCount(Wrappers.<Role>query().lambda().eq(Role::getRoleAlias, RoleConstant.ADMINISTRATOR).in(Role::getId, roleIds));
|
|
|
if (!AuthUtil.isAdministrator() && administratorCount > 0L) {
|
|
@@ -156,9 +168,32 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
|
|
|
roleMenus.add(roleMenu);
|
|
|
}));
|
|
|
}
|
|
|
+
|
|
|
+ // 组装配置-计量
|
|
|
+ if (menuMeasureIds != null && menuMeasureIds.size() >= 1) {
|
|
|
+ roleIds.forEach(roleId -> menuMeasureIds.forEach(menuIdC -> {
|
|
|
+ RoleMenu roleMenu = new RoleMenu();
|
|
|
+ roleMenu.setRoleId(roleId);
|
|
|
+ roleMenu.setMenuId(Long.valueOf(menuIdC.split("---")[0]));
|
|
|
+ roleMenu.setStatus(menuIdC.split("---")[1]);
|
|
|
+ roleMenus.add(roleMenu);
|
|
|
+ }));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 组装配置-安全
|
|
|
+ if (menuSecureIds != null && menuSecureIds.size() >= 1) {
|
|
|
+ roleIds.forEach(roleId -> menuSecureIds.forEach(menuIdC -> {
|
|
|
+ RoleMenu roleMenu = new RoleMenu();
|
|
|
+ roleMenu.setRoleId(roleId);
|
|
|
+ roleMenu.setMenuId(Long.valueOf(menuIdC.split("---")[0]));
|
|
|
+ roleMenu.setStatus(menuIdC.split("---")[1]);
|
|
|
+ roleMenus.add(roleMenu);
|
|
|
+ }));
|
|
|
+ }
|
|
|
+
|
|
|
// 新增配置
|
|
|
- boolean b = roleMenuService.saveBatch(roleMenus);
|
|
|
- System.out.println("ddd");
|
|
|
+ roleMenuService.saveBatch(roleMenus);
|
|
|
+
|
|
|
// 递归设置下属角色菜单集合
|
|
|
if (menuIds != null && menuIds.size() >= 1) {
|
|
|
recursionRoleMenu(roleIds, menuIds);
|
|
@@ -175,6 +210,12 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
|
|
|
if (menuLarIds != null && menuLarIds.size() >= 1) {
|
|
|
recursionRoleMenu(roleIds, menuLarIds); //征拆
|
|
|
}
|
|
|
+ if (menuMeasureIds != null && menuMeasureIds.size() >= 1) {
|
|
|
+ recursionRoleMenu(roleIds, menuMeasureIds); //计量
|
|
|
+ }
|
|
|
+ if (menuSecureIds != null && menuSecureIds.size() >= 1) {
|
|
|
+ recursionRoleMenu(roleIds, menuSecureIds); //安全
|
|
|
+ }
|
|
|
|
|
|
return true;
|
|
|
}
|
|
@@ -187,7 +228,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
|
|
|
String id = split[0]; //id
|
|
|
menuIds.add(Long.valueOf(id));
|
|
|
}
|
|
|
- //
|
|
|
+
|
|
|
for (Long roleId : roleIds) {
|
|
|
List<Role> roleList = roleMapper.getRoleDeptInfoByParentId(roleId + "");
|
|
|
roleList.forEach(role -> {
|