Showing
1 changed file
with
17 additions
and
1 deletions
1 | package com.yoho.search.service.scene.pages; | 1 | package com.yoho.search.service.scene.pages; |
2 | 2 | ||
3 | +import com.alibaba.fastjson.JSONObject; | ||
3 | import com.yoho.search.base.utils.SearchPageIdDefine; | 4 | import com.yoho.search.base.utils.SearchPageIdDefine; |
4 | import com.yoho.search.common.SearchRequestParams; | 5 | import com.yoho.search.common.SearchRequestParams; |
5 | import com.yoho.search.common.utils.SearchApiResultUtils; | 6 | import com.yoho.search.common.utils.SearchApiResultUtils; |
6 | import com.yoho.search.models.SearchApiResult; | 7 | import com.yoho.search.models.SearchApiResult; |
7 | import com.yoho.search.service.scene.pages.entrance.ProductListSwitchService; | 8 | import com.yoho.search.service.scene.pages.entrance.ProductListSwitchService; |
9 | +import com.yoho.search.service.scene.pages.selections.PageAggregationHelper; | ||
8 | import com.yoho.search.service.scene.pages.selections.PageSelectionsBrandsService; | 10 | import com.yoho.search.service.scene.pages.selections.PageSelectionsBrandsService; |
9 | import com.yoho.search.service.scene.pages.selections.PageSelectionsService; | 11 | import com.yoho.search.service.scene.pages.selections.PageSelectionsService; |
10 | import org.apache.commons.lang.StringUtils; | 12 | import org.apache.commons.lang.StringUtils; |
@@ -14,6 +16,9 @@ import org.springframework.beans.factory.annotation.Autowired; | @@ -14,6 +16,9 @@ import org.springframework.beans.factory.annotation.Autowired; | ||
14 | import org.springframework.stereotype.Service; | 16 | import org.springframework.stereotype.Service; |
15 | 17 | ||
16 | import java.util.Map; | 18 | import java.util.Map; |
19 | +import java.util.concurrent.CompletableFuture; | ||
20 | +import java.util.concurrent.ExecutorService; | ||
21 | +import java.util.concurrent.Executors; | ||
17 | 22 | ||
18 | @Service | 23 | @Service |
19 | public class ZqPageSceneService extends AbstractPageSceneService { | 24 | public class ZqPageSceneService extends AbstractPageSceneService { |
@@ -26,6 +31,10 @@ public class ZqPageSceneService extends AbstractPageSceneService { | @@ -26,6 +31,10 @@ public class ZqPageSceneService extends AbstractPageSceneService { | ||
26 | private PageSelectionsService pageSelectionsService; | 31 | private PageSelectionsService pageSelectionsService; |
27 | @Autowired | 32 | @Autowired |
28 | private PageSelectionsBrandsService scenePageSelectionsBrandsService; | 33 | private PageSelectionsBrandsService scenePageSelectionsBrandsService; |
34 | + @Autowired | ||
35 | + private PageAggregationHelper pageAggregationHelper; | ||
36 | + | ||
37 | + private ExecutorService executorService = Executors.newFixedThreadPool(20); | ||
29 | 38 | ||
30 | @Override | 39 | @Override |
31 | public String pageId() { | 40 | public String pageId() { |
@@ -47,7 +56,14 @@ public class ZqPageSceneService extends AbstractPageSceneService { | @@ -47,7 +56,14 @@ public class ZqPageSceneService extends AbstractPageSceneService { | ||
47 | // 1、添加默认参数 | 56 | // 1、添加默认参数 |
48 | this.addParamsToParamMap(paramMap); | 57 | this.addParamsToParamMap(paramMap); |
49 | // 2、返回商品列表 | 58 | // 2、返回商品列表 |
50 | - return sceneProductListService.productList(paramMap); | 59 | + CompletableFuture<SearchApiResult> productListFuture = CompletableFuture.supplyAsync(() -> sceneProductListService.productList(this.newParamMap(paramMap)), executorService); |
60 | + CompletableFuture<SearchApiResult> customizeTagFuture = CompletableFuture.supplyAsync(() -> pageAggregationHelper.sceneAggCustomizeTag(this.newParamMap(paramMap)), | ||
61 | + executorService); | ||
62 | + SearchApiResult productList = productListFuture.get(); | ||
63 | + SearchApiResult customizeTags = customizeTagFuture.get(); | ||
64 | + JSONObject jsonObject = (JSONObject) productList.getData(); | ||
65 | + jsonObject.put(CUSTOMIZE_TAG_LIST, customizeTags.getData()); | ||
66 | + return productList; | ||
51 | } catch (Exception e) { | 67 | } catch (Exception e) { |
52 | return SearchApiResultUtils.errorSearchApiResult(logger, paramMap, e); | 68 | return SearchApiResultUtils.errorSearchApiResult(logger, paramMap, e); |
53 | } | 69 | } |
-
Please register or login to post a comment