Authored by qinchao

fix : 商品收藏分页信息 重设

... ... @@ -52,16 +52,19 @@ public class FavoriteController {
vo.setLimit(20);
}
int total = favoriteService.numFavorite(vo);
int pageSize = vo.getLimit();
//分页获取收藏的商品id,
List<String> productIds= favoriteService.listFavorite(vo);
logger.info("After call ufo.user.favoriteList result productIds is {}", productIds);
if(productIds==null||productIds.size()<=0){
if(total<=0||productIds==null||productIds.size()<=0){
JSONObject jo=new JSONObject();
jo.put("total",0);
jo.put("page_total",0);
jo.put("page",1);
jo.put("page_size",0);
jo.put("page_size",pageSize);
jo.put("product_list",new ArrayList<>());
return new com.yohoufo.common.ApiResponse.ApiResponseBuilder().data(jo).code(200).message("listFavorite data is null").build();
}
... ... @@ -78,6 +81,17 @@ public class FavoriteController {
,limit,page
);
if(productApiResponse!=null&&productApiResponse.getData()!=null){
int frontPage = vo.getPage();
JSONObject jo=(JSONObject)productApiResponse.getData();
jo.put("total", total);
jo.put("page_total",total%pageSize==0?total/pageSize:((total/pageSize)+1));
jo.put("page",frontPage);
jo.put("page_size",pageSize);
//重设
productApiResponse.setData(jo);
}
logger.info("After call ufo.user.favoriteList result productIds is {} ,productApiResponse is {} ", productIds ,productApiResponse);
return productApiResponse;
}
... ...