老师,ProductServiceImpl类的getProductByKeywordCategory方法貌似有个小bug
来源:8-9 商品管理模块所有功能自测
botao555
2017-06-26
Category category = categoryMapper.selectByPrimaryKey(categoryId);
if(category == null && StringUtils.isBlank(keyword)){
//没有该分类,并且还没有关键字,这个时候返回一个空的结果集,不报错
PageHelper.startPage(pageNum,pageSize);
List<ProductListVo> productListVoList = Lists.newArrayList();
PageInfo pageInfo = new PageInfo(productListVoList);
return ServerResponse.createBySuccess(pageInfo);
}
categoryIdList = iCategoryService.selectCategoryAndChildrenById(category.getId()).getData();当前端传过来的categoryId找不到对应的Category,而keyword又不为空时,下面的category.getId()会报空指针。所以我觉得给categoryIdList赋值时应该再单独判断下category是不是为null。
写回答
1回答
-
hi同学!!首先接受我的赞可以么~
非常赞!考虑的很仔细,是的,这块也是我在写的时候逻辑空没做好,你做的话可以让他更完善。
所以我觉得给categoryIdList赋值时应该再单独判断下category是不是为null。
赞同赞同~~在二期我们会做全局异常~~
012017-06-29
相似问题