Authored by zhaojun2

PROMOTION LIST FIX

@@ -121,7 +121,7 @@ public class SceneAggregationsHelper { @@ -121,7 +121,7 @@ public class SceneAggregationsHelper {
121 @SearchCacheAble(cacheName = "AGG_PROMOTION", cacheInMinute = 15, excludeParams = { "uid", "udid", "order", "page", "viewNum", "yh_channel"}) 121 @SearchCacheAble(cacheName = "AGG_PROMOTION", cacheInMinute = 15, excludeParams = { "uid", "udid", "order", "page", "viewNum", "yh_channel"})
122 public List<RecommendPromotionAggVO> aggPromotion(Map<String, String> paramMap) { 122 public List<RecommendPromotionAggVO> aggPromotion(Map<String, String> paramMap) {
123 try { 123 try {
124 - IAggregation aggregation = aggregationFactoryService.getRecommendPromotionAggregation(500); 124 + IAggregation aggregation = aggregationFactoryService.getRecommendPromotionAggregation(50);
125 Object ids = this.getAggregationResponse(aggregation, paramMap); 125 Object ids = this.getAggregationResponse(aggregation, paramMap);
126 if(ids == null){ 126 if(ids == null){
127 return Collections.emptyList(); 127 return Collections.emptyList();
@@ -4,11 +4,11 @@ import java.util.ArrayList; @@ -4,11 +4,11 @@ import java.util.ArrayList;
4 import java.util.List; 4 import java.util.List;
5 import java.util.Map; 5 import java.util.Map;
6 6
  7 +import com.yoho.search.base.utils.CollectionUtils;
7 import com.yoho.search.models.RecommendPromotionAggVO; 8 import com.yoho.search.models.RecommendPromotionAggVO;
8 import com.yoho.search.service.helper.SearchCommonHelper; 9 import com.yoho.search.service.helper.SearchCommonHelper;
9 import com.yoho.search.service.scene.aggregations.SceneAggregationsHelper; 10 import com.yoho.search.service.scene.aggregations.SceneAggregationsHelper;
10 import com.yoho.search.service.scene.common.SceneRecommendBrandsService; 11 import com.yoho.search.service.scene.common.SceneRecommendBrandsService;
11 -import org.apache.commons.lang.StringUtils;  
12 import org.elasticsearch.index.query.BoolQueryBuilder; 12 import org.elasticsearch.index.query.BoolQueryBuilder;
13 import org.elasticsearch.search.aggregations.AbstractAggregationBuilder; 13 import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
14 import org.elasticsearch.search.aggregations.Aggregation; 14 import org.elasticsearch.search.aggregations.Aggregation;
@@ -208,23 +208,16 @@ public class PromotionAggregationsService extends AbstractCacheAbleService { @@ -208,23 +208,16 @@ public class PromotionAggregationsService extends AbstractCacheAbleService {
208 } 208 }
209 209
210 public SearchApiResult aggPromotions(Map<String, String> paramMap){ 210 public SearchApiResult aggPromotions(Map<String, String> paramMap){
211 - int page = StringUtils.isBlank(paramMap.get("page")) ? 1 : Integer.parseInt(paramMap.get("page"));  
212 - int pageSize = StringUtils.isBlank(paramMap.get("viewNum")) ? 10 : Integer.parseInt(paramMap.get("viewNum"));  
213 - if (page < 1 || pageSize < 0 || page * pageSize > 1000000) {  
214 - return new SearchApiResult().setCode(400).setMessage("分页参数不合法");  
215 - }  
216 - if (pageSize > 100) {  
217 - pageSize = 100;  
218 - }  
219 - List<RecommendPromotionAggVO> recommendPromotionAggVOS = sceneAggregationsHelper.aggPromotion(paramMap); 211 + int size = 10;
220 JSONObject jsonObject = new JSONObject(); 212 JSONObject jsonObject = new JSONObject();
221 - jsonObject.put("page", page);  
222 - jsonObject.put("total", recommendPromotionAggVOS.size());  
223 - jsonObject.put("page_size", pageSize);  
224 - jsonObject.put("page_total", searchCommonHelper.getTotalPage(recommendPromotionAggVOS.size(), pageSize));  
225 - jsonObject.put("promotionList", sceneAggregationsHelper.subRecommendPromotions(recommendPromotionAggVOS, page, pageSize)); 213 + List<RecommendPromotionAggVO> recommendPromotionAggVOS = sceneAggregationsHelper.aggPromotion(paramMap);
  214 + if (recommendPromotionAggVOS.size() > size) {
  215 + jsonObject.put("promotionList", CollectionUtils.safeSubList(recommendPromotionAggVOS, 0, size));
  216 + } else {
  217 + jsonObject.put("promotionList", recommendPromotionAggVOS);
  218 + }
  219 +
226 return new SearchApiResult().setData(jsonObject); 220 return new SearchApiResult().setData(jsonObject);
227 } 221 }
228 222
229 -  
230 } 223 }