stream流处理

List<Dish> records = pageInfo.getRecords() ;
List<DishDto> list = records.stream().map((item)一>{
    DishDto dishDto = new DishDto();
    BeanUtils.copyProperties(item, dishDto);
    Long categoryId = item.getCategoryId();
    Category category = categoryService.getById(categoryId);
    String categoryName = category.getName();
    dishDto.setCategoryName(categoryName);

    return dishDto;
}).collect(Collectors.tolist());

猜你喜欢

转载自blog.csdn.net/m0_72297711/article/details/129113527