...
|
...
|
@@ -4,11 +4,11 @@ import java.util.ArrayList; |
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
import com.yoho.search.base.utils.CollectionUtils;
|
|
|
import com.yoho.search.models.RecommendPromotionAggVO;
|
|
|
import com.yoho.search.service.helper.SearchCommonHelper;
|
|
|
import com.yoho.search.service.scene.aggregations.SceneAggregationsHelper;
|
|
|
import com.yoho.search.service.scene.common.SceneRecommendBrandsService;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
|
|
import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
|
|
|
import org.elasticsearch.search.aggregations.Aggregation;
|
...
|
...
|
@@ -208,23 +208,16 @@ public class PromotionAggregationsService extends AbstractCacheAbleService { |
|
|
}
|
|
|
|
|
|
public SearchApiResult aggPromotions(Map<String, String> paramMap){
|
|
|
int page = StringUtils.isBlank(paramMap.get("page")) ? 1 : Integer.parseInt(paramMap.get("page"));
|
|
|
int pageSize = StringUtils.isBlank(paramMap.get("viewNum")) ? 10 : Integer.parseInt(paramMap.get("viewNum"));
|
|
|
if (page < 1 || pageSize < 0 || page * pageSize > 1000000) {
|
|
|
return new SearchApiResult().setCode(400).setMessage("分页参数不合法");
|
|
|
}
|
|
|
if (pageSize > 100) {
|
|
|
pageSize = 100;
|
|
|
}
|
|
|
List<RecommendPromotionAggVO> recommendPromotionAggVOS = sceneAggregationsHelper.aggPromotion(paramMap);
|
|
|
int size = 10;
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("page", page);
|
|
|
jsonObject.put("total", recommendPromotionAggVOS.size());
|
|
|
jsonObject.put("page_size", pageSize);
|
|
|
jsonObject.put("page_total", searchCommonHelper.getTotalPage(recommendPromotionAggVOS.size(), pageSize));
|
|
|
jsonObject.put("promotionList", sceneAggregationsHelper.subRecommendPromotions(recommendPromotionAggVOS, page, pageSize));
|
|
|
List<RecommendPromotionAggVO> recommendPromotionAggVOS = sceneAggregationsHelper.aggPromotion(paramMap);
|
|
|
if (recommendPromotionAggVOS.size() > size) {
|
|
|
jsonObject.put("promotionList", CollectionUtils.safeSubList(recommendPromotionAggVOS, 0, size));
|
|
|
} else {
|
|
|
jsonObject.put("promotionList", recommendPromotionAggVOS);
|
|
|
}
|
|
|
|
|
|
return new SearchApiResult().setData(jsonObject);
|
|
|
}
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|