在list方法中
1 2 | @RequestParam (value = "keyword" ,required = false )String keyword, @RequestParam (value = "categoryId" ,required = false )Integer categoryId, |
但是在ProductServiceImpl.java中的getProductByKeywordCategory方法里,又对这两个参数进行是否为空的校验:
1 2 3 | if (StringUtils.isBlank(keyword) && categoryId == null ){ return ServerResponse.createByErrorCodeMessage(ResponseCode.ILLEGAL_ARGUMENT.getCode(),ResponseCode.ILLEGAL_ARGUMENT.getDesc()); } |
这样是不是自相矛盾呢?
这样的话,在测试过程中,发现不传递keyword categoryId这两个参数就会报ILLEGAL_ARGUMENT的错误,把上面的校验部分的代码注释掉就不会出现这样的问题了,但是视频中测试过程中不传递categoryId这个参数并没有报错,而且结果正常