fix: 商品列表超限不返回数量修复

This commit is contained in:
张松 2024-12-16 14:50:23 +08:00
parent 89e202fa15
commit 9320f400df
2 changed files with 7 additions and 3 deletions

View File

@ -16,9 +16,11 @@ import com.chaozhanggui.system.cashierservice.mapper.MpShopUnitMapper;
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.BeanUtil;
import com.chaozhanggui.system.cashierservice.util.DateUtils;
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
import com.chaozhanggui.system.cashierservice.util.PageHelperUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -123,7 +125,7 @@ public class ProductService {
public Result queryNewCommodityInfo(String shopId, String categoryId, String commdityName, String tableId, int page, int pageSize, String masterId) {
List<TbProduct> tbProductWithBLOBs=null;
PageHelperUtil.startPage(page,pageSize);
PageHelperUtil.startPage(page, pageSize);
if(ObjectUtil.isEmpty(categoryId)){
tbProductWithBLOBs=tbProductMapper.selectByShopIdAndCheckGrounding(shopId,commdityName);
}else {
@ -171,6 +173,7 @@ public class ProductService {
});
}
PageInfo pageInfo=new PageInfo(tbProductWithBLOBs);
pageInfo.setList(pageInfo.isIsLastPage() ? pageInfo.getList() : new ArrayList());
return Result.success(CodeEnum.SUCCESS,pageInfo);
}

View File

@ -1,5 +1,6 @@
package com.chaozhanggui.system.cashierservice.util;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
public class PageHelperUtil {
@ -7,7 +8,7 @@ public class PageHelperUtil {
/**
* 解决页数超限 仍返回数据问题
*/
public static void startPage(int page, int pageSize) {
PageHelper.startPage(page, pageSize, true, false, false);
public static Page<Object> startPage(int page, int pageSize) {
return PageHelper.startPage(page, pageSize, true, true, false);
}
}