显示不出数据
来源:5-4 买家商品-api(下)
 
			Genius_Wang
2022-01-07
虽然不知道为什么之前的问题不给回答,是因为太简单了吗,(救命,我已经提了五六次了)真的没有神仙能帮忙一下吗
视频里这个输出,我输出在这里
网页是空,一定要看在这里
代码是没错的,一定要看在这里
@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;
}
}
写回答
	2回答
- 
				  廖师兄 2022-01-20 看图。  012022-01-26 012022-01-26
- 
				  廖师兄 2022-01-07 一定一定一定要学会打断点。控制台只打印语句,看不出问题的。要在代码打断点看,先看有没有从数据库查出来。有人连错数据库,一直查不出来。能查出来后再看数据拼装有没有错。 022022-01-20
相似问题
 
						