虽然不知道为什么之前的问题不给回答,是因为太简单了吗,(救命,我已经提了五六次了)真的没有神仙能帮忙一下吗
视频里这个输出,我输出在这里
网页是空,一定要看在这里
代码是没错的,一定要看在这里
@RestController
@RequestMapping("/buyer/product")
public class BuyerProductController {
@Autowired
private ProductService productService;
@Autowired
private CategoryService categoryService;
@GetMapping("/list")
public ResultVO list(){
List<ProductInfo> productInfoList = productService.findUpAll();
List<Integer> categoryTypeList = productInfoList.stream()
.map(e -> e.getCategoryType())
.collect(Collectors.toList());
List<ProductCategory> productCategoryList = categoryService.findByCategoryTypeIn(categoryTypeList);
List<ProductVO> productVOList = new ArrayList<>();
for (ProductCategory productCategory: productCategoryList) {
ProductVO productVO = new ProductVO();
productVO.setCategoryType(productCategory.getCategoryType());
productVO.setCategoryName(productCategory.getCategoryName());
List<ProductInfoVO> productInfoVOList = new ArrayList<>();
for (ProductInfo productInfo: productInfoList) {
if (productInfo.getCategoryType().equals(productCategory.getCategoryType())) {
ProductInfoVO productInfoVO = new ProductInfoVO();
BeanUtils.copyProperties(productInfo, productInfoVO);
productInfoVOList.add(productInfoVO);
}
}
productVO.setProductInfoVOList(productInfoVOList);
productVOList.add(productVO);
}
ResultVO resultVO = new ResultVO();
resultVO.setData(productVOList);
resultVO.setCode(0);
resultVO.setMsg("hahahaha");
return resultVO;
}
}