当某个功能用到get传参方法时
@GetMapping("/list/{categoryId}")
传入参数需要用到此注解: @ApiImplicitParams
@ApiImplicitParams({
@ApiImplicitParam(value = "分类id",name = "categoryId",required = true,dataType = "long"),
@ApiImplicitParam(value = "页码",name = "page",required = true,dataType = "int"),
@ApiImplicitParam(value = "每页条数",name = "pageSize",required = true,dataType = "int")
})
public JsonResult<JsonPage<SpuListItemVO>> listSpuByPage(
@PathVariable Long categoryId, Integer page, Integer pageSize){
JsonPage<SpuListItemVO> jsonPage = frontProductService.listSpuByCategoryId(categoryId, page, pageSize);
return JsonResult.ok(jsonPage);
}
使用@PathVariable注解在路径中灵活传入参数,@ApiImplicitParams中的@ApiImplicitParam注解用以说明参数作用,在knife4j中调试时有至关重要的作用