|
|
|
@ -76,7 +76,6 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public boolean grant(@NotEmpty List<Long> roleIds, @NotEmpty List<Long> menuIds, List<Long> dataScopeIds, List<Long> apiScopeIds) { |
|
|
|
|
// 菜单权限模块
|
|
|
|
|
// 删除角色配置的菜单集合
|
|
|
|
|
roleMenuService.remove(Wrappers.<RoleMenu>update().lambda().in(RoleMenu::getRoleId, roleIds)); |
|
|
|
|
// 组装配置
|
|
|
|
@ -90,39 +89,33 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
|
|
|
|
|
// 新增配置
|
|
|
|
|
roleMenuService.saveBatch(roleMenus); |
|
|
|
|
|
|
|
|
|
// 数据权限模块
|
|
|
|
|
if (CollectionUtil.isNotEmpty(dataScopeIds)) { |
|
|
|
|
// 删除角色配置的数据权限集合
|
|
|
|
|
roleScopeService.remove(Wrappers.<RoleScope>update().lambda().in(RoleScope::getRoleId, roleIds)); |
|
|
|
|
// 组装配置
|
|
|
|
|
List<RoleScope> roleScopes = new ArrayList<>(); |
|
|
|
|
roleIds.forEach(roleId -> dataScopeIds.forEach(scopeId -> { |
|
|
|
|
RoleScope roleScope = new RoleScope(); |
|
|
|
|
roleScope.setScopeCategory(DATA_SCOPE_CATEGORY); |
|
|
|
|
roleScope.setRoleId(roleId); |
|
|
|
|
roleScope.setScopeId(scopeId); |
|
|
|
|
roleScopes.add(roleScope); |
|
|
|
|
})); |
|
|
|
|
// 新增配置
|
|
|
|
|
roleScopeService.saveBatch(roleScopes); |
|
|
|
|
} |
|
|
|
|
// 删除角色配置的数据权限集合
|
|
|
|
|
roleScopeService.remove(Wrappers.<RoleScope>update().lambda().in(RoleScope::getRoleId, roleIds)); |
|
|
|
|
// 组装配置
|
|
|
|
|
List<RoleScope> roleDataScopes = new ArrayList<>(); |
|
|
|
|
roleIds.forEach(roleId -> dataScopeIds.forEach(scopeId -> { |
|
|
|
|
RoleScope roleScope = new RoleScope(); |
|
|
|
|
roleScope.setScopeCategory(DATA_SCOPE_CATEGORY); |
|
|
|
|
roleScope.setRoleId(roleId); |
|
|
|
|
roleScope.setScopeId(scopeId); |
|
|
|
|
roleDataScopes.add(roleScope); |
|
|
|
|
})); |
|
|
|
|
// 新增配置
|
|
|
|
|
roleScopeService.saveBatch(roleDataScopes); |
|
|
|
|
|
|
|
|
|
// 接口权限模块
|
|
|
|
|
if (CollectionUtil.isNotEmpty(apiScopeIds)) { |
|
|
|
|
// 删除角色配置的数据权限集合
|
|
|
|
|
roleScopeService.remove(Wrappers.<RoleScope>update().lambda().eq(RoleScope::getScopeCategory, API_SCOPE_CATEGORY).in(RoleScope::getRoleId, roleIds)); |
|
|
|
|
// 组装配置
|
|
|
|
|
List<RoleScope> roleScopes = new ArrayList<>(); |
|
|
|
|
roleIds.forEach(roleId -> apiScopeIds.forEach(scopeId -> { |
|
|
|
|
RoleScope roleScope = new RoleScope(); |
|
|
|
|
roleScope.setScopeCategory(API_SCOPE_CATEGORY); |
|
|
|
|
roleScope.setScopeId(scopeId); |
|
|
|
|
roleScope.setRoleId(roleId); |
|
|
|
|
roleScopes.add(roleScope); |
|
|
|
|
})); |
|
|
|
|
// 新增配置
|
|
|
|
|
roleScopeService.saveBatch(roleScopes); |
|
|
|
|
} |
|
|
|
|
// 删除角色配置的数据权限集合
|
|
|
|
|
roleScopeService.remove(Wrappers.<RoleScope>update().lambda().eq(RoleScope::getScopeCategory, API_SCOPE_CATEGORY).in(RoleScope::getRoleId, roleIds)); |
|
|
|
|
// 组装配置
|
|
|
|
|
List<RoleScope> roleApiScopes = new ArrayList<>(); |
|
|
|
|
roleIds.forEach(roleId -> apiScopeIds.forEach(scopeId -> { |
|
|
|
|
RoleScope roleScope = new RoleScope(); |
|
|
|
|
roleScope.setScopeCategory(API_SCOPE_CATEGORY); |
|
|
|
|
roleScope.setScopeId(scopeId); |
|
|
|
|
roleScope.setRoleId(roleId); |
|
|
|
|
roleApiScopes.add(roleScope); |
|
|
|
|
})); |
|
|
|
|
// 新增配置
|
|
|
|
|
roleScopeService.saveBatch(roleApiScopes); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
@ -134,7 +127,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<String> getRoleAliases(String roleIds) { |
|
|
|
|
return baseMapper.getRoleAliases(Func.toStrArray(roleIds)); |
|
|
|
|
return baseMapper.getRoleAliases(Func.toLongArray(roleIds)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|