Showing
11 changed files
with
268 additions
and
11 deletions
1 | +package com.yoho.search.service.restapi.scene; | ||
2 | + | ||
3 | +import java.util.Map; | ||
4 | + | ||
5 | +import javax.servlet.http.HttpServletRequest; | ||
6 | + | ||
7 | +import org.springframework.beans.factory.annotation.Autowired; | ||
8 | +import org.springframework.stereotype.Controller; | ||
9 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
10 | +import org.springframework.web.bind.annotation.RequestMethod; | ||
11 | +import org.springframework.web.bind.annotation.ResponseBody; | ||
12 | + | ||
13 | +import com.yoho.search.service.servicenew.scene.BrandSceneService; | ||
14 | +import com.yoho.search.service.utils.HttpServletRequestUtils; | ||
15 | +import com.yoho.search.service.vo.SearchApiResult; | ||
16 | + | ||
17 | +/** | ||
18 | + * 品牌列表 | ||
19 | + * | ||
20 | + * @author gufei.hu | ||
21 | + * | ||
22 | + */ | ||
23 | +@Controller | ||
24 | +public class BrandSceneController { | ||
25 | + | ||
26 | + @Autowired | ||
27 | + private BrandSceneService brandSceneService; | ||
28 | + | ||
29 | + /** | ||
30 | + * 品牌页列表 | ||
31 | + * | ||
32 | + * @return | ||
33 | + */ | ||
34 | + @RequestMapping(method = RequestMethod.GET, value = "/brand/productList") | ||
35 | + @ResponseBody | ||
36 | + public SearchApiResult shopProductList(HttpServletRequest request) { | ||
37 | + Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request); | ||
38 | + return brandSceneService.productList(paramMap); | ||
39 | + } | ||
40 | + | ||
41 | + /** | ||
42 | + * 品牌页筛选 | ||
43 | + * | ||
44 | + * @return | ||
45 | + */ | ||
46 | + @RequestMapping(method = RequestMethod.GET, value = "/brand/aggregations") | ||
47 | + @ResponseBody | ||
48 | + public SearchApiResult shopAggregations(HttpServletRequest request) { | ||
49 | + Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request); | ||
50 | + return brandSceneService.aggregations(paramMap); | ||
51 | + } | ||
52 | +} |
@@ -17,15 +17,16 @@ import com.yoho.search.service.vo.SearchApiResult; | @@ -17,15 +17,16 @@ import com.yoho.search.service.vo.SearchApiResult; | ||
17 | 17 | ||
18 | /** | 18 | /** |
19 | * 商品池接口 | 19 | * 商品池接口 |
20 | + * | ||
20 | * @author gufei.hu | 21 | * @author gufei.hu |
21 | * | 22 | * |
22 | */ | 23 | */ |
23 | @Controller | 24 | @Controller |
24 | public class ProductPoolSceneControoler { | 25 | public class ProductPoolSceneControoler { |
25 | - | 26 | + |
26 | @Autowired | 27 | @Autowired |
27 | private ProductPoolSceneService productPoolService; | 28 | private ProductPoolSceneService productPoolService; |
28 | - | 29 | + |
29 | /** | 30 | /** |
30 | * 搜索商品池商品列表 | 31 | * 搜索商品池商品列表 |
31 | * | 32 | * |
@@ -39,4 +40,30 @@ public class ProductPoolSceneControoler { | @@ -39,4 +40,30 @@ public class ProductPoolSceneControoler { | ||
39 | Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request); | 40 | Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request); |
40 | return productPoolService.productPool(paramMap); | 41 | return productPoolService.productPool(paramMap); |
41 | } | 42 | } |
43 | + | ||
44 | + /** | ||
45 | + * 商品池列表 | ||
46 | + * | ||
47 | + * @param request | ||
48 | + * @return | ||
49 | + */ | ||
50 | + @RequestMapping(method = RequestMethod.GET, value = "/pool/productList") | ||
51 | + @ResponseBody | ||
52 | + public SearchApiResult poolProductList(HttpServletRequest request) { | ||
53 | + Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request); | ||
54 | + return productPoolService.productList(paramMap); | ||
55 | + } | ||
56 | + | ||
57 | + /** | ||
58 | + * 商品池筛选 | ||
59 | + * | ||
60 | + * @param request | ||
61 | + * @return | ||
62 | + */ | ||
63 | + @RequestMapping(method = RequestMethod.GET, value = "/pool/aggregations") | ||
64 | + @ResponseBody | ||
65 | + public SearchApiResult poolAggregations(HttpServletRequest request) { | ||
66 | + Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request); | ||
67 | + return productPoolService.aggregations(paramMap); | ||
68 | + } | ||
42 | } | 69 | } |
1 | package com.yoho.search.service.servicenew.impl; | 1 | package com.yoho.search.service.servicenew.impl; |
2 | 2 | ||
3 | -import java.util.List; | ||
4 | import java.util.Map; | 3 | import java.util.Map; |
5 | 4 | ||
6 | import org.apache.commons.lang.StringUtils; | 5 | import org.apache.commons.lang.StringUtils; |
7 | import org.elasticsearch.index.query.BoolQueryBuilder; | 6 | import org.elasticsearch.index.query.BoolQueryBuilder; |
8 | import org.elasticsearch.index.query.QueryBuilders; | 7 | import org.elasticsearch.index.query.QueryBuilders; |
9 | -import org.elasticsearch.search.aggregations.Aggregation; | ||
10 | import org.springframework.beans.factory.annotation.Autowired; | 8 | import org.springframework.beans.factory.annotation.Autowired; |
11 | 9 | ||
12 | -import com.alibaba.fastjson.JSONObject; | ||
13 | import com.yoho.search.base.utils.ConvertUtils; | 10 | import com.yoho.search.base.utils.ConvertUtils; |
14 | -import com.yoho.search.core.es.agg.IAggregation; | ||
15 | import com.yoho.search.service.service.helper.SearchParamHelper; | 11 | import com.yoho.search.service.service.helper.SearchParamHelper; |
16 | import com.yoho.search.service.service.helper.SearchSortHelper; | 12 | import com.yoho.search.service.service.helper.SearchSortHelper; |
17 | 13 |
1 | +package com.yoho.search.service.servicenew.scene; | ||
2 | + | ||
3 | +import java.util.Map; | ||
4 | + | ||
5 | +import org.apache.commons.lang3.StringUtils; | ||
6 | +import org.slf4j.Logger; | ||
7 | +import org.slf4j.LoggerFactory; | ||
8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
9 | + | ||
10 | +import com.yoho.search.base.utils.SearchPageIdDefine; | ||
11 | +import com.yoho.search.service.servicenew.scene.common.AbstractSceneService; | ||
12 | +import com.yoho.search.service.servicenew.scene.common.SceneProductListService; | ||
13 | +import com.yoho.search.service.servicenew.scene.common.SceneSelectionsService; | ||
14 | +import com.yoho.search.service.utils.SearchApiResultUtils; | ||
15 | +import com.yoho.search.service.utils.SearchRequestParams; | ||
16 | +import com.yoho.search.service.vo.SearchApiResult; | ||
17 | + | ||
18 | +public class BrandSceneService extends AbstractSceneService { | ||
19 | + | ||
20 | + private static final Logger logger = LoggerFactory.getLogger(BrandSceneService.class); | ||
21 | + | ||
22 | + @Autowired | ||
23 | + private SceneProductListService sceneProductListService; | ||
24 | + @Autowired | ||
25 | + private SceneSelectionsService sceneSelectionsService; | ||
26 | + | ||
27 | + @Override | ||
28 | + public String pageId() { | ||
29 | + return SearchPageIdDefine.PAGE_ID_BRAND; | ||
30 | + } | ||
31 | + | ||
32 | + @Override | ||
33 | + public void addParamsToParamMap(Map<String, String> paramMap) { | ||
34 | + super.addDefaultParamsToParamMap(paramMap); | ||
35 | + } | ||
36 | + | ||
37 | + @Override | ||
38 | + public SearchApiResult productList(Map<String, String> paramMap) { | ||
39 | + try { | ||
40 | + // 0、参数校验 | ||
41 | + if (StringUtils.isBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_BRAND))) { | ||
42 | + return new SearchApiResult().setCode(400).setMessage("请传brand参数"); | ||
43 | + } | ||
44 | + // 1、添加默认参数 | ||
45 | + this.addParamsToParamMap(paramMap); | ||
46 | + // 2、返回商品列表 | ||
47 | + return sceneProductListService.productList(paramMap); | ||
48 | + } catch (Exception e) { | ||
49 | + logger.error("[func=BrandProductList][params=" + paramMap + "]", e); | ||
50 | + return SearchApiResultUtils.errorSearchApiResult("BrandProductList", paramMap, e); | ||
51 | + } | ||
52 | + } | ||
53 | + | ||
54 | + @Override | ||
55 | + public SearchApiResult aggregations(Map<String, String> paramMap) { | ||
56 | + try { | ||
57 | + // 0、参数校验 | ||
58 | + if (StringUtils.isBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_BRAND))) { | ||
59 | + return new SearchApiResult().setCode(400).setMessage("请传brand参数"); | ||
60 | + } | ||
61 | + // 1、添加默认参数 | ||
62 | + this.addParamsToParamMap(paramMap); | ||
63 | + // 2、返回聚合结果 | ||
64 | + return sceneSelectionsService.aggregations(paramMap); | ||
65 | + } catch (Exception e) { | ||
66 | + logger.error("[func=BrandAggregations][params=" + paramMap + "]", e); | ||
67 | + return SearchApiResultUtils.errorSearchApiResult("BrandAggregations", paramMap, e); | ||
68 | + } | ||
69 | + } | ||
70 | +} |
@@ -62,6 +62,10 @@ public class FuzzySceneService extends AbstractSceneService { | @@ -62,6 +62,10 @@ public class FuzzySceneService extends AbstractSceneService { | ||
62 | @Override | 62 | @Override |
63 | public SearchApiResult productList(Map<String, String> paramMap) { | 63 | public SearchApiResult productList(Map<String, String> paramMap) { |
64 | try { | 64 | try { |
65 | + // 0、参数校验 | ||
66 | + if (StringUtils.isBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_QUERY))) { | ||
67 | + return new SearchApiResult().setCode(400).setMessage("请传query参数"); | ||
68 | + } | ||
65 | // 1、添加默认参数 | 69 | // 1、添加默认参数 |
66 | this.addParamsToParamMap(paramMap); | 70 | this.addParamsToParamMap(paramMap); |
67 | // 2、获取商品列表 | 71 | // 2、获取商品列表 |
@@ -84,6 +88,10 @@ public class FuzzySceneService extends AbstractSceneService { | @@ -84,6 +88,10 @@ public class FuzzySceneService extends AbstractSceneService { | ||
84 | @Override | 88 | @Override |
85 | public SearchApiResult aggregations(Map<String, String> paramMap) { | 89 | public SearchApiResult aggregations(Map<String, String> paramMap) { |
86 | try { | 90 | try { |
91 | + // 0、参数校验 | ||
92 | + if (StringUtils.isBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_QUERY))) { | ||
93 | + return new SearchApiResult().setCode(400).setMessage("请传query参数"); | ||
94 | + } | ||
87 | // 1、添加默认参数 | 95 | // 1、添加默认参数 |
88 | this.addParamsToParamMap(paramMap); | 96 | this.addParamsToParamMap(paramMap); |
89 | // 2、返回聚合结果 | 97 | // 2、返回聚合结果 |
@@ -8,17 +8,25 @@ import org.slf4j.LoggerFactory; | @@ -8,17 +8,25 @@ import org.slf4j.LoggerFactory; | ||
8 | import org.springframework.beans.factory.annotation.Autowired; | 8 | import org.springframework.beans.factory.annotation.Autowired; |
9 | import org.springframework.stereotype.Service; | 9 | import org.springframework.stereotype.Service; |
10 | 10 | ||
11 | +import com.yoho.search.base.utils.SearchPageIdDefine; | ||
11 | import com.yoho.search.service.servicenew.IProductListService; | 12 | import com.yoho.search.service.servicenew.IProductListService; |
13 | +import com.yoho.search.service.servicenew.scene.common.AbstractSceneService; | ||
14 | +import com.yoho.search.service.servicenew.scene.common.SceneProductListService; | ||
15 | +import com.yoho.search.service.servicenew.scene.common.SceneSelectionsService; | ||
12 | import com.yoho.search.service.utils.SearchApiResultUtils; | 16 | import com.yoho.search.service.utils.SearchApiResultUtils; |
13 | import com.yoho.search.service.vo.SearchApiResult; | 17 | import com.yoho.search.service.vo.SearchApiResult; |
14 | 18 | ||
15 | @Service | 19 | @Service |
16 | -public class ProductPoolSceneService { | 20 | +public class ProductPoolSceneService extends AbstractSceneService { |
17 | 21 | ||
18 | private static final Logger logger = LoggerFactory.getLogger(ProductPoolSceneService.class); | 22 | private static final Logger logger = LoggerFactory.getLogger(ProductPoolSceneService.class); |
19 | 23 | ||
20 | @Autowired | 24 | @Autowired |
21 | private IProductListService productListService; | 25 | private IProductListService productListService; |
26 | + @Autowired | ||
27 | + private SceneProductListService sceneProductListService; | ||
28 | + @Autowired | ||
29 | + private SceneSelectionsService sceneSelectionsService; | ||
22 | 30 | ||
23 | /** | 31 | /** |
24 | * 将discount_score:desc 转为 pools.id:asc | 32 | * 将discount_score:desc 转为 pools.id:asc |
@@ -45,4 +53,56 @@ public class ProductPoolSceneService { | @@ -45,4 +53,56 @@ public class ProductPoolSceneService { | ||
45 | return SearchApiResultUtils.errorSearchApiResult("productPool", paramMap, e); | 53 | return SearchApiResultUtils.errorSearchApiResult("productPool", paramMap, e); |
46 | } | 54 | } |
47 | } | 55 | } |
56 | + | ||
57 | + /** | ||
58 | + * 将discount_score:desc 转为 pools.id:asc | ||
59 | + * | ||
60 | + * @param paramMap | ||
61 | + * @return | ||
62 | + */ | ||
63 | + @Override | ||
64 | + public void addParamsToParamMap(Map<String, String> paramMap) { | ||
65 | + super.addDefaultParamsToParamMap(paramMap); | ||
66 | + // 1)排序接口兼容【按商品池导入顺序排序】 | ||
67 | + String sortFields = paramMap.get("order"); | ||
68 | + if (!StringUtils.isBlank(sortFields) && sortFields.contains("discount_score")) { | ||
69 | + paramMap.put("order", "pools.id:asc"); | ||
70 | + } | ||
71 | + } | ||
72 | + | ||
73 | + @Override | ||
74 | + public String pageId() { | ||
75 | + return SearchPageIdDefine.PAGE_ID_POOL; | ||
76 | + } | ||
77 | + | ||
78 | + public SearchApiResult productList(Map<String, String> paramMap) { | ||
79 | + // 1)如果poolId为空返回 | ||
80 | + if (StringUtils.isBlank(paramMap.get("filter_poolId"))) { | ||
81 | + return new SearchApiResult().setCode(400).setMessage("filter_poolId参数为空"); | ||
82 | + } | ||
83 | + // 2)获取商品列表 | ||
84 | + try { | ||
85 | + this.addParamsToParamMap(paramMap); | ||
86 | + return sceneProductListService.productList(paramMap); | ||
87 | + } catch (Exception e) { | ||
88 | + logger.error("[func=PoolProductList][params=" + paramMap + "]", e); | ||
89 | + return SearchApiResultUtils.errorSearchApiResult("PoolProductList", paramMap, e); | ||
90 | + } | ||
91 | + } | ||
92 | + | ||
93 | + @Override | ||
94 | + public SearchApiResult aggregations(Map<String, String> paramMap) { | ||
95 | + // 1)如果poolId为空返回 | ||
96 | + if (StringUtils.isBlank(paramMap.get("filter_poolId"))) { | ||
97 | + return new SearchApiResult().setCode(400).setMessage("filter_poolId参数为空"); | ||
98 | + } | ||
99 | + // 2)获取商品池筛选项 | ||
100 | + try { | ||
101 | + this.addParamsToParamMap(paramMap); | ||
102 | + return sceneSelectionsService.aggregations(paramMap); | ||
103 | + } catch (Exception e) { | ||
104 | + logger.error("[func=PoolAggregations][params=" + paramMap + "]", e); | ||
105 | + return SearchApiResultUtils.errorSearchApiResult("PoolAggregations", paramMap, e); | ||
106 | + } | ||
107 | + } | ||
48 | } | 108 | } |
@@ -2,6 +2,7 @@ package com.yoho.search.service.servicenew.scene; | @@ -2,6 +2,7 @@ package com.yoho.search.service.servicenew.scene; | ||
2 | 2 | ||
3 | import java.util.Map; | 3 | import java.util.Map; |
4 | 4 | ||
5 | +import org.apache.commons.lang3.StringUtils; | ||
5 | import org.slf4j.Logger; | 6 | import org.slf4j.Logger; |
6 | import org.slf4j.LoggerFactory; | 7 | import org.slf4j.LoggerFactory; |
7 | import org.springframework.beans.factory.annotation.Autowired; | 8 | import org.springframework.beans.factory.annotation.Autowired; |
@@ -12,12 +13,13 @@ import com.yoho.search.service.servicenew.scene.common.AbstractSceneService; | @@ -12,12 +13,13 @@ import com.yoho.search.service.servicenew.scene.common.AbstractSceneService; | ||
12 | import com.yoho.search.service.servicenew.scene.common.SceneProductListService; | 13 | import com.yoho.search.service.servicenew.scene.common.SceneProductListService; |
13 | import com.yoho.search.service.servicenew.scene.common.SceneSelectionsService; | 14 | import com.yoho.search.service.servicenew.scene.common.SceneSelectionsService; |
14 | import com.yoho.search.service.utils.SearchApiResultUtils; | 15 | import com.yoho.search.service.utils.SearchApiResultUtils; |
16 | +import com.yoho.search.service.utils.SearchRequestParams; | ||
15 | import com.yoho.search.service.vo.SearchApiResult; | 17 | import com.yoho.search.service.vo.SearchApiResult; |
16 | 18 | ||
17 | @Service | 19 | @Service |
18 | public class ShopSceneService extends AbstractSceneService { | 20 | public class ShopSceneService extends AbstractSceneService { |
19 | 21 | ||
20 | - private static final Logger logger = LoggerFactory.getLogger(NewArrivalSceneService.class); | 22 | + private static final Logger logger = LoggerFactory.getLogger(ShopSceneService.class); |
21 | 23 | ||
22 | @Autowired | 24 | @Autowired |
23 | private SceneProductListService sceneProductListService; | 25 | private SceneProductListService sceneProductListService; |
@@ -37,6 +39,10 @@ public class ShopSceneService extends AbstractSceneService { | @@ -37,6 +39,10 @@ public class ShopSceneService extends AbstractSceneService { | ||
37 | @Override | 39 | @Override |
38 | public SearchApiResult productList(Map<String, String> paramMap) { | 40 | public SearchApiResult productList(Map<String, String> paramMap) { |
39 | try { | 41 | try { |
42 | + // 0、参数校验 | ||
43 | + if (StringUtils.isBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_SHOP))) { | ||
44 | + return new SearchApiResult().setCode(400).setMessage("请传shop参数"); | ||
45 | + } | ||
40 | // 1、添加默认参数 | 46 | // 1、添加默认参数 |
41 | this.addParamsToParamMap(paramMap); | 47 | this.addParamsToParamMap(paramMap); |
42 | // 2、返回商品列表 | 48 | // 2、返回商品列表 |
@@ -50,6 +56,10 @@ public class ShopSceneService extends AbstractSceneService { | @@ -50,6 +56,10 @@ public class ShopSceneService extends AbstractSceneService { | ||
50 | @Override | 56 | @Override |
51 | public SearchApiResult aggregations(Map<String, String> paramMap) { | 57 | public SearchApiResult aggregations(Map<String, String> paramMap) { |
52 | try { | 58 | try { |
59 | + // 0、参数校验 | ||
60 | + if (StringUtils.isBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_SHOP))) { | ||
61 | + return new SearchApiResult().setCode(400).setMessage("请传shop参数"); | ||
62 | + } | ||
53 | // 1、添加默认参数 | 63 | // 1、添加默认参数 |
54 | this.addParamsToParamMap(paramMap); | 64 | this.addParamsToParamMap(paramMap); |
55 | // 2、返回聚合结果 | 65 | // 2、返回聚合结果 |
@@ -55,6 +55,22 @@ public class SortSceneService extends AbstractSceneService { | @@ -55,6 +55,22 @@ public class SortSceneService extends AbstractSceneService { | ||
55 | 55 | ||
56 | private ExecutorService executorService = Executors.newFixedThreadPool(100); | 56 | private ExecutorService executorService = Executors.newFixedThreadPool(100); |
57 | 57 | ||
58 | + private boolean checkParam(Map<String, String> paramMap) { | ||
59 | + if (StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_MAXSORT))) { | ||
60 | + return true; | ||
61 | + } | ||
62 | + if (StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_MIDDLESORT))) { | ||
63 | + return true; | ||
64 | + } | ||
65 | + if (StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_SMALLSORT))) { | ||
66 | + return true; | ||
67 | + } | ||
68 | + if (StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_COMMONSORT))) { | ||
69 | + return true; | ||
70 | + } | ||
71 | + return false; | ||
72 | + } | ||
73 | + | ||
58 | /** | 74 | /** |
59 | * @特殊参数: | 75 | * @特殊参数: |
60 | * @1、paramNum-获取规则数量的接口 | 76 | * @1、paramNum-获取规则数量的接口 |
@@ -63,6 +79,10 @@ public class SortSceneService extends AbstractSceneService { | @@ -63,6 +79,10 @@ public class SortSceneService extends AbstractSceneService { | ||
63 | @Override | 79 | @Override |
64 | public SearchApiResult productList(Map<String, String> paramMap) { | 80 | public SearchApiResult productList(Map<String, String> paramMap) { |
65 | try { | 81 | try { |
82 | + // 0、必传品类相关参数 | ||
83 | + if (!this.checkParam(paramMap)) { | ||
84 | + return new SearchApiResult().setCode(400).setMessage("请传品类相关参数"); | ||
85 | + } | ||
66 | // 1、添加默认参数 | 86 | // 1、添加默认参数 |
67 | this.addParamsToParamMap(paramMap); | 87 | this.addParamsToParamMap(paramMap); |
68 | // 2、获取商品列表 | 88 | // 2、获取商品列表 |
@@ -93,6 +113,10 @@ public class SortSceneService extends AbstractSceneService { | @@ -93,6 +113,10 @@ public class SortSceneService extends AbstractSceneService { | ||
93 | @Override | 113 | @Override |
94 | public SearchApiResult aggregations(Map<String, String> paramMap) { | 114 | public SearchApiResult aggregations(Map<String, String> paramMap) { |
95 | try { | 115 | try { |
116 | + // 0、必传品类相关参数 | ||
117 | + if (!this.checkParam(paramMap)) { | ||
118 | + return new SearchApiResult().setCode(400).setMessage("请传品类相关参数"); | ||
119 | + } | ||
96 | // 1、添加默认参数 | 120 | // 1、添加默认参数 |
97 | this.addParamsToParamMap(paramMap); | 121 | this.addParamsToParamMap(paramMap); |
98 | // 2、返回聚合结果 | 122 | // 2、返回聚合结果 |
@@ -2,6 +2,7 @@ package com.yoho.search.service.servicenew.scene; | @@ -2,6 +2,7 @@ package com.yoho.search.service.servicenew.scene; | ||
2 | 2 | ||
3 | import java.util.Map; | 3 | import java.util.Map; |
4 | 4 | ||
5 | +import org.apache.commons.lang.StringUtils; | ||
5 | import org.slf4j.Logger; | 6 | import org.slf4j.Logger; |
6 | import org.slf4j.LoggerFactory; | 7 | import org.slf4j.LoggerFactory; |
7 | import org.springframework.beans.factory.annotation.Autowired; | 8 | import org.springframework.beans.factory.annotation.Autowired; |
@@ -12,6 +13,7 @@ import com.yoho.search.service.servicenew.scene.common.AbstractSceneService; | @@ -12,6 +13,7 @@ import com.yoho.search.service.servicenew.scene.common.AbstractSceneService; | ||
12 | import com.yoho.search.service.servicenew.scene.common.SceneProductListService; | 13 | import com.yoho.search.service.servicenew.scene.common.SceneProductListService; |
13 | import com.yoho.search.service.servicenew.scene.common.SceneSelectionsService; | 14 | import com.yoho.search.service.servicenew.scene.common.SceneSelectionsService; |
14 | import com.yoho.search.service.utils.SearchApiResultUtils; | 15 | import com.yoho.search.service.utils.SearchApiResultUtils; |
16 | +import com.yoho.search.service.utils.SearchRequestParams; | ||
15 | import com.yoho.search.service.vo.SearchApiResult; | 17 | import com.yoho.search.service.vo.SearchApiResult; |
16 | 18 | ||
17 | @Service | 19 | @Service |
@@ -28,7 +30,7 @@ public class ZqSceneService extends AbstractSceneService { | @@ -28,7 +30,7 @@ public class ZqSceneService extends AbstractSceneService { | ||
28 | public String pageId() { | 30 | public String pageId() { |
29 | return SearchPageIdDefine.PAGE_ID_ZQ; | 31 | return SearchPageIdDefine.PAGE_ID_ZQ; |
30 | } | 32 | } |
31 | - | 33 | + |
32 | @Override | 34 | @Override |
33 | public void addParamsToParamMap(Map<String, String> paramMap) { | 35 | public void addParamsToParamMap(Map<String, String> paramMap) { |
34 | super.addDefaultParamsToParamMap(paramMap); | 36 | super.addDefaultParamsToParamMap(paramMap); |
@@ -37,6 +39,10 @@ public class ZqSceneService extends AbstractSceneService { | @@ -37,6 +39,10 @@ public class ZqSceneService extends AbstractSceneService { | ||
37 | @Override | 39 | @Override |
38 | public SearchApiResult productList(Map<String, String> paramMap) { | 40 | public SearchApiResult productList(Map<String, String> paramMap) { |
39 | try { | 41 | try { |
42 | + // 0、参数校验 | ||
43 | + if (StringUtils.isBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ISPROMOTION))) { | ||
44 | + return new SearchApiResult().setCode(400).setMessage("请传promotion参数"); | ||
45 | + } | ||
40 | // 1、添加默认参数 | 46 | // 1、添加默认参数 |
41 | this.addParamsToParamMap(paramMap); | 47 | this.addParamsToParamMap(paramMap); |
42 | // 2、返回商品列表 | 48 | // 2、返回商品列表 |
@@ -50,6 +56,10 @@ public class ZqSceneService extends AbstractSceneService { | @@ -50,6 +56,10 @@ public class ZqSceneService extends AbstractSceneService { | ||
50 | @Override | 56 | @Override |
51 | public SearchApiResult aggregations(Map<String, String> paramMap) { | 57 | public SearchApiResult aggregations(Map<String, String> paramMap) { |
52 | try { | 58 | try { |
59 | + // 0、参数校验 | ||
60 | + if (StringUtils.isBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_ISPROMOTION))) { | ||
61 | + return new SearchApiResult().setCode(400).setMessage("请传promotion参数"); | ||
62 | + } | ||
53 | // 1、添加默认参数 | 63 | // 1、添加默认参数 |
54 | this.addParamsToParamMap(paramMap); | 64 | this.addParamsToParamMap(paramMap); |
55 | // 2、返回聚合结果 | 65 | // 2、返回聚合结果 |
@@ -199,7 +199,7 @@ public class SceneSelectionsService extends BaseService { | @@ -199,7 +199,7 @@ public class SceneSelectionsService extends BaseService { | ||
199 | return new JSONObject(); | 199 | return new JSONObject(); |
200 | } | 200 | } |
201 | } | 201 | } |
202 | - | 202 | + |
203 | private JSONObject getFiltersResult(Map<String, String> paramMap, BoolQueryBuilder mustFilter) { | 203 | private JSONObject getFiltersResult(Map<String, String> paramMap, BoolQueryBuilder mustFilter) { |
204 | try { | 204 | try { |
205 | SearchParam searchParam = searchParamHelper.buildWithMustFilter(paramMap, mustFilter); | 205 | SearchParam searchParam = searchParamHelper.buildWithMustFilter(paramMap, mustFilter); |
@@ -41,7 +41,7 @@ public class SearchRequestParams { | @@ -41,7 +41,7 @@ public class SearchRequestParams { | ||
41 | 41 | ||
42 | public static final String PARAM_SEARCH_SPECIALOFFER = "specialoffer"; // ◆是否为促销品 | 42 | public static final String PARAM_SEARCH_SPECIALOFFER = "specialoffer"; // ◆是否为促销品 |
43 | public static final String PARAM_SEARCH_ISSALES = "sales"; // ◆查询是否销售(有货不销售) | 43 | public static final String PARAM_SEARCH_ISSALES = "sales"; // ◆查询是否销售(有货不销售) |
44 | - public static final String PARAM_SEARCH_ISPROMOTION = "promotion"; // 特价类型 | 44 | + public static final String PARAM_SEARCH_ISPROMOTION = "promotion"; // 专区id |
45 | public static final String PARAM_SEARCH_VIPDISCOUNTTYPE = "vdt"; // ◆VIP折扣类型 | 45 | public static final String PARAM_SEARCH_VIPDISCOUNTTYPE = "vdt"; // ◆VIP折扣类型 |
46 | public static final String PARAM_SEARCH_PD = "p_d"; // ◆促销折扣浮点值(如0.7) | 46 | public static final String PARAM_SEARCH_PD = "p_d"; // ◆促销折扣浮点值(如0.7) |
47 | public static final String PARAM_SEARCH_PDINT = "p_d_int"; // ◆促销折扣整数值(如7) | 47 | public static final String PARAM_SEARCH_PDINT = "p_d_int"; // ◆促销折扣整数值(如7) |
-
Please register or login to post a comment