Authored by hugufei

专区列表支持自定义标签

package com.yoho.search.service.scene.pages;
import com.alibaba.fastjson.JSONObject;
import com.yoho.search.base.utils.SearchPageIdDefine;
import com.yoho.search.common.SearchRequestParams;
import com.yoho.search.common.utils.SearchApiResultUtils;
import com.yoho.search.models.SearchApiResult;
import com.yoho.search.service.scene.pages.entrance.ProductListSwitchService;
import com.yoho.search.service.scene.pages.selections.PageAggregationHelper;
import com.yoho.search.service.scene.pages.selections.PageSelectionsBrandsService;
import com.yoho.search.service.scene.pages.selections.PageSelectionsService;
import org.apache.commons.lang.StringUtils;
... ... @@ -14,6 +16,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Service
public class ZqPageSceneService extends AbstractPageSceneService {
... ... @@ -26,6 +31,10 @@ public class ZqPageSceneService extends AbstractPageSceneService {
private PageSelectionsService pageSelectionsService;
@Autowired
private PageSelectionsBrandsService scenePageSelectionsBrandsService;
@Autowired
private PageAggregationHelper pageAggregationHelper;
private ExecutorService executorService = Executors.newFixedThreadPool(20);
@Override
public String pageId() {
... ... @@ -47,7 +56,14 @@ public class ZqPageSceneService extends AbstractPageSceneService {
// 1、添加默认参数
this.addParamsToParamMap(paramMap);
// 2、返回商品列表
return sceneProductListService.productList(paramMap);
CompletableFuture<SearchApiResult> productListFuture = CompletableFuture.supplyAsync(() -> sceneProductListService.productList(this.newParamMap(paramMap)), executorService);
CompletableFuture<SearchApiResult> customizeTagFuture = CompletableFuture.supplyAsync(() -> pageAggregationHelper.sceneAggCustomizeTag(this.newParamMap(paramMap)),
executorService);
SearchApiResult productList = productListFuture.get();
SearchApiResult customizeTags = customizeTagFuture.get();
JSONObject jsonObject = (JSONObject) productList.getData();
jsonObject.put(CUSTOMIZE_TAG_LIST, customizeTags.getData());
return productList;
} catch (Exception e) {
return SearchApiResultUtils.errorSearchApiResult(logger, paramMap, e);
}
... ...