Authored by mali

Merge branch 'dev'

@@ -52,16 +52,19 @@ public class FavoriteController { @@ -52,16 +52,19 @@ public class FavoriteController {
52 vo.setLimit(20); 52 vo.setLimit(20);
53 } 53 }
54 54
  55 + int total = favoriteService.numFavorite(vo);
  56 + int pageSize = vo.getLimit();
  57 +
55 //分页获取收藏的商品id, 58 //分页获取收藏的商品id,
56 List<String> productIds= favoriteService.listFavorite(vo); 59 List<String> productIds= favoriteService.listFavorite(vo);
57 logger.info("After call ufo.user.favoriteList result productIds is {}", productIds); 60 logger.info("After call ufo.user.favoriteList result productIds is {}", productIds);
58 61
59 - if(productIds==null||productIds.size()<=0){ 62 + if(total<=0||productIds==null||productIds.size()<=0){
60 JSONObject jo=new JSONObject(); 63 JSONObject jo=new JSONObject();
61 jo.put("total",0); 64 jo.put("total",0);
62 jo.put("page_total",0); 65 jo.put("page_total",0);
63 jo.put("page",1); 66 jo.put("page",1);
64 - jo.put("page_size",0); 67 + jo.put("page_size",pageSize);
65 jo.put("product_list",new ArrayList<>()); 68 jo.put("product_list",new ArrayList<>());
66 return new com.yohoufo.common.ApiResponse.ApiResponseBuilder().data(jo).code(200).message("listFavorite data is null").build(); 69 return new com.yohoufo.common.ApiResponse.ApiResponseBuilder().data(jo).code(200).message("listFavorite data is null").build();
67 } 70 }
@@ -78,6 +81,17 @@ public class FavoriteController { @@ -78,6 +81,17 @@ public class FavoriteController {
78 ,limit,page 81 ,limit,page
79 ); 82 );
80 83
  84 + if(productApiResponse!=null&&productApiResponse.getData()!=null){
  85 + int frontPage = vo.getPage();
  86 + JSONObject jo=(JSONObject)productApiResponse.getData();
  87 + jo.put("total", total);
  88 + jo.put("page_total",total%pageSize==0?total/pageSize:((total/pageSize)+1));
  89 + jo.put("page",frontPage);
  90 + jo.put("page_size",pageSize);
  91 + //重设
  92 + productApiResponse.setData(jo);
  93 + }
  94 +
81 logger.info("After call ufo.user.favoriteList result productIds is {} ,productApiResponse is {} ", productIds ,productApiResponse); 95 logger.info("After call ufo.user.favoriteList result productIds is {} ,productApiResponse is {} ", productIds ,productApiResponse);
82 return productApiResponse; 96 return productApiResponse;
83 } 97 }