fix: 商品分页默认参数

This commit is contained in:
Gadfly 2021-08-17 18:33:48 +08:00
parent a4caa73d06
commit 41703b1f7e

View File

@ -38,7 +38,12 @@ public class GoodsController {
@ApiImplicitParam(name = "isAsc", value = "是否升序", example = "false", paramType = "query", dataType = "Boolean") @ApiImplicitParam(name = "isAsc", value = "是否升序", example = "false", paramType = "query", dataType = "Boolean")
}) })
@GetMapping @GetMapping
public Result list(Integer page, Integer limit, String name, Long categoryId, String orderBy, Boolean isAsc) { public Result<List<GoodsVO>> list(@RequestParam(name = "page", defaultValue = "1") Integer page,
@RequestParam(name = "limit", defaultValue = "10") Integer limit,
String name,
Long categoryId,
@RequestParam(name = "orderBy", defaultValue = "id") String orderBy,
@RequestParam(name = "isAsc", defaultValue = "false") Boolean isAsc) {
Page<PmsSpu> pageResult = goodsService.page(new Page<>(page, limit), new QueryWrapper<PmsSpu>() Page<PmsSpu> pageResult = goodsService.page(new Page<>(page, limit), new QueryWrapper<PmsSpu>()
.eq(categoryId != null, "category_id", categoryId) .eq(categoryId != null, "category_id", categoryId)
.like(StrUtil.isNotBlank(name), "name", name) .like(StrUtil.isNotBlank(name), "name", name)