|
@@ -85,13 +85,11 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public boolean grant(@NotEmpty List<Long> roleIds, List<Long> menuIds, List<Long> dataScopeIds, List<Long> apiScopeIds, List<Long> tableOwners) {
|
|
|
-
|
|
|
-
|
|
|
- return grantRoleMenu(roleIds, menuIds) && grantDataScope(roleIds, dataScopeIds) && grantApiScope(roleIds, apiScopeIds) && submitRoleAndTableOwner(roleIds, tableOwners);
|
|
|
+ public boolean grant(@NotEmpty List<Long> roleIds, List<Long> menuIds, List<Long> menuClientIds, List<Long> dataScopeIds, List<Long> apiScopeIds, List<Long> tableOwners) {
|
|
|
+ return grantRoleMenu(roleIds, menuIds, menuClientIds) && grantDataScope(roleIds, dataScopeIds) && grantApiScope(roleIds, apiScopeIds) && submitRoleAndTableOwner(roleIds, tableOwners);
|
|
|
}
|
|
|
|
|
|
- private boolean grantRoleMenu(List<Long> roleIds, List<Long> menuIds) {
|
|
|
+ private boolean grantRoleMenu(List<Long> roleIds, List<Long> menuIds, List<Long> menuClientIds) {
|
|
|
// 防止越权配置超管角色
|
|
|
Long administratorCount = baseMapper.selectCount(Wrappers.<Role>query().lambda().eq(Role::getRoleAlias, RoleConstant.ADMINISTRATOR).in(Role::getId, roleIds));
|
|
|
if (!AuthUtil.isAdministrator() && administratorCount > 0L) {
|
|
@@ -104,7 +102,8 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
|
|
|
}
|
|
|
// 删除角色配置的菜单集合
|
|
|
roleMenuService.remove(Wrappers.<RoleMenu>update().lambda().in(RoleMenu::getRoleId, roleIds));
|
|
|
- // 组装配置
|
|
|
+
|
|
|
+ // 组装配置 - 后台
|
|
|
List<RoleMenu> roleMenus = new ArrayList<>();
|
|
|
roleIds.forEach(roleId -> menuIds.forEach(menuId -> {
|
|
|
RoleMenu roleMenu = new RoleMenu();
|
|
@@ -112,10 +111,22 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
|
|
|
roleMenu.setMenuId(menuId);
|
|
|
roleMenus.add(roleMenu);
|
|
|
}));
|
|
|
+
|
|
|
+ // 组装配置-客户端
|
|
|
+ roleIds.forEach(roleId -> menuClientIds.forEach(menuIdC -> {
|
|
|
+ RoleMenu roleMenu = new RoleMenu();
|
|
|
+ roleMenu.setRoleId(roleId);
|
|
|
+ roleMenu.setMenuId(menuIdC);
|
|
|
+ roleMenus.add(roleMenu);
|
|
|
+ }));
|
|
|
+
|
|
|
// 新增配置
|
|
|
roleMenuService.saveBatch(roleMenus);
|
|
|
+
|
|
|
// 递归设置下属角色菜单集合
|
|
|
recursionRoleMenu(roleIds, menuIds);
|
|
|
+ recursionRoleMenu(roleIds, menuClientIds);
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -254,15 +265,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
|
|
|
return baseMapper.selectList(Wrappers.<Role>query().lambda().eq(Role::getParentId, 0));
|
|
|
}
|
|
|
|
|
|
- private Boolean removeRoleAndPostByRid(String ids) {
|
|
|
- Integer row = roleMapper.deleteRoleAndPostByRid(ids);
|
|
|
- if (row > 0) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean submitRoleAndTableOwner(List<Long> roleIds, List<Long> tableOwners) {
|
|
|
for (Long role : roleIds) {
|
|
|
List<WbsTableOwnerRole> list = baseMapper.selectRoleAndTableOwnerListByRoleId(role);
|
|
@@ -285,7 +288,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
|
|
|
}
|
|
|
|
|
|
if (diffRent.size() == 0) {
|
|
|
- throw new ServiceException("角色表单权限未进行任何操作");
|
|
|
+ return true;
|
|
|
} else {
|
|
|
if (tableOwnerValuesOut.size() > tableOwnerValuesIn.size()) {
|
|
|
//新增
|
|
@@ -306,12 +309,6 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public List<WbsTableOwnerRole> searchRoleAndTableOwnerList(String roleId) {
|
|
|
- return baseMapper.selectRoleAndTableOwnerList(roleId);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
private static List<String> getDiffRent(List<String> list1, List<String> list2) {
|
|
|
List<String> diff = new ArrayList<String>();
|
|
|
List<String> maxList = list1;
|