List<IndexResourceResult> appResourceList = appResourceService.queryList(appResourceRequest);
// id - ModuleLibraryDO
Map<Long, AppModuleDTO> libraryDOMap = appModuleList.stream().collect(Collectors.toMap(AppModuleDTO::getId, appModuleDTO -> appModuleDTO));
// parentId - ModuleLibraryDO
Map<Long, List<AppModuleDTO>> subLibraryDOMap = appModuleList.stream().filter(appModuleDTO -> Objects.nonNull(appModuleDTO.getParentId())).collect(Collectors.groupingBy(AppModuleDTO::getParentId));
// moduleId - List<CommonResourceDO>
Map<Long, List<IndexResourceResult>> commonResourceMap = appResourceList.stream().filter(indexResourceResult -> Objects.nonNull(indexResourceResult.getModuleId())).collect(Collectors.groupingBy(IndexResourceResult::getModuleId));
// 遍历框架
stream流实际运用
最新推荐文章于 2024-10-12 22:35:37 发布