|
@@ -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));
|
|
|
226
|
- return new SearchApiResult().setData(jsonObject);
|
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);
|
227
|
}
|
218
|
}
|
228
|
|
219
|
|
|
|
220
|
+ return new SearchApiResult().setData(jsonObject);
|
|
|
221
|
+ }
|
229
|
|
222
|
|
230
|
} |
223
|
} |