Authored by 胡古飞

抽取isProductList至controller

@@ -29,6 +29,7 @@ public class ProductListController { @@ -29,6 +29,7 @@ public class ProductListController {
29 @ResponseBody 29 @ResponseBody
30 public SearchApiResult productList(HttpServletRequest request) { 30 public SearchApiResult productList(HttpServletRequest request) {
31 Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request); 31 Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
  32 + paramMap.put("isProductList", "Y");// 加个参数,表明是商品列表
32 return productListService.productList(paramMap); 33 return productListService.productList(paramMap);
33 } 34 }
34 35
@@ -41,6 +42,7 @@ public class ProductListController { @@ -41,6 +42,7 @@ public class ProductListController {
41 @ResponseBody 42 @ResponseBody
42 public SearchApiResult getESDsl(HttpServletRequest request) { 43 public SearchApiResult getESDsl(HttpServletRequest request) {
43 Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request); 44 Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
  45 + paramMap.put("isProductList", "Y");// 加个参数,表明是商品列表
44 return productListService.getESDsl(paramMap); 46 return productListService.getESDsl(paramMap);
45 } 47 }
46 48
@@ -138,8 +138,8 @@ public class SearchServiceHelper { @@ -138,8 +138,8 @@ public class SearchServiceHelper {
138 } 138 }
139 139
140 private boolean isNeedDeScoreBrandSearch(Map<String, String> paramMap) { 140 private boolean isNeedDeScoreBrandSearch(Map<String, String> paramMap) {
141 - //如果品牌降分总开关未开启,则直接返回  
142 - if(!dynamicConfig.deScoreBrandOpen()){ 141 + // 如果品牌降分总开关未开启,则直接返回
  142 + if (!dynamicConfig.deScoreBrandOpen()) {
143 return false; 143 return false;
144 } 144 }
145 // 如果是按售价或者折扣排序或品牌也或店铺页,则降分不生效 145 // 如果是按售价或者折扣排序或品牌也或店铺页,则降分不生效
@@ -294,17 +294,17 @@ public class SearchServiceHelper { @@ -294,17 +294,17 @@ public class SearchServiceHelper {
294 if (StringUtils.isBlank(keyword)) { 294 if (StringUtils.isBlank(keyword)) {
295 return QueryBuilders.matchAllQuery(); 295 return QueryBuilders.matchAllQuery();
296 } 296 }
297 - //0、处理is_encode的情况,编码转换  
298 - String is_encode = paramMap.get("is_encode");  
299 - if(StringUtils.isNotBlank(is_encode)&&is_encode.equals("1")){  
300 - try {  
301 - keyword = URLDecoder.decode(keyword, "UTF-8");  
302 - } catch (UnsupportedEncodingException e) {  
303 - logger.warn(e.getMessage(),e);  
304 - }  
305 - }  
306 - paramMap.put("query", keyword);  
307 - 297 + // 0、处理is_encode的情况,编码转换
  298 + String is_encode = paramMap.get("is_encode");
  299 + if (StringUtils.isNotBlank(is_encode) && is_encode.equals("1")) {
  300 + try {
  301 + keyword = URLDecoder.decode(keyword, "UTF-8");
  302 + } catch (UnsupportedEncodingException e) {
  303 + logger.warn(e.getMessage(), e);
  304 + }
  305 + }
  306 + paramMap.put("query", keyword);
  307 +
308 // 1、处理查询中包含性别的情况 308 // 1、处理查询中包含性别的情况
309 this.dealKeywordOfGender(keyword, paramMap); 309 this.dealKeywordOfGender(keyword, paramMap);
310 310
@@ -372,15 +372,12 @@ public class SearchServiceHelper { @@ -372,15 +372,12 @@ public class SearchServiceHelper {
372 queryBuilder = this.buildPersonalSearch(queryBuilder, paramMap); 372 queryBuilder = this.buildPersonalSearch(queryBuilder, paramMap);
373 373
374 String dynamicRuleValue = dynamicSearchRuleHelper.getDynamicRuleValue(paramMap); 374 String dynamicRuleValue = dynamicSearchRuleHelper.getDynamicRuleValue(paramMap);
375 - if(StringUtils.isEmpty(dynamicRuleValue) || "-1".equals(dynamicRuleValue))  
376 - { 375 + if (StringUtils.isEmpty(dynamicRuleValue) || "-1".equals(dynamicRuleValue)) {
377 queryBuilder = this.buildDeScoreBrandSearch(queryBuilder, paramMap); 376 queryBuilder = this.buildDeScoreBrandSearch(queryBuilder, paramMap);
378 queryBuilder = this.buildGlobalSearch(queryBuilder, paramMap); 377 queryBuilder = this.buildGlobalSearch(queryBuilder, paramMap);
379 - }  
380 - else { 378 + } else {
381 queryBuilder = dynamicSearchRuleHelper.buildDynamicSerach(queryBuilder, paramMap, dynamicRuleValue); 379 queryBuilder = dynamicSearchRuleHelper.buildDynamicSerach(queryBuilder, paramMap, dynamicRuleValue);
382 } 380 }
383 -  
384 return queryBuilder; 381 return queryBuilder;
385 } 382 }
386 383
@@ -513,7 +510,7 @@ public class SearchServiceHelper { @@ -513,7 +510,7 @@ public class SearchServiceHelper {
513 */ 510 */
514 public void setDefaultSearchField(MultiMatchQueryBuilder queryBuilder, Map<String, String> paramMap) { 511 public void setDefaultSearchField(MultiMatchQueryBuilder queryBuilder, Map<String, String> paramMap) {
515 List<String> fields = dynamicSearchRuleHelper.getDynamicSearchFields(paramMap); 512 List<String> fields = dynamicSearchRuleHelper.getDynamicSearchFields(paramMap);
516 - if(CollectionUtils.isEmpty(fields)){ 513 + if (CollectionUtils.isEmpty(fields)) {
517 fields = ISearchConstants.SEARCH_DEFAULT_FIELD; 514 fields = ISearchConstants.SEARCH_DEFAULT_FIELD;
518 } 515 }
519 516
@@ -604,7 +601,7 @@ public class SearchServiceHelper { @@ -604,7 +601,7 @@ public class SearchServiceHelper {
604 if ("Y".equals(paramMap.get(SearchRequestParams.PARAM_SEARCH_GLOBAL_FILTER_BRAND))) { 601 if ("Y".equals(paramMap.get(SearchRequestParams.PARAM_SEARCH_GLOBAL_FILTER_BRAND))) {
605 boolFilter.mustNot(QueryBuilders.termQuery("isForbiddenSortBrand", 1)); 602 boolFilter.mustNot(QueryBuilders.termQuery("isForbiddenSortBrand", 1));
606 } 603 }
607 - 604 +
608 // 店铺 605 // 店铺
609 if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_SHOP) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_SHOP)) 606 if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_SHOP) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_SHOP))
610 && !SearchRequestParams.PARAM_SEARCH_SHOP.equals(filterParamName)) { 607 && !SearchRequestParams.PARAM_SEARCH_SHOP.equals(filterParamName)) {
@@ -146,7 +146,6 @@ public class ProductListServiceImpl implements IProductListService { @@ -146,7 +146,6 @@ public class ProductListServiceImpl implements IProductListService {
146 } 146 }
147 147
148 // 2)构建基本查询参数 148 // 2)构建基本查询参数
149 - paramMap.put("isProductList", "Y");// 加个参数,表明是商品列表  
150 SearchParam searchParam = new SearchParam(); 149 SearchParam searchParam = new SearchParam();
151 searchParam.setQuery(searchServiceHelper.constructQueryBuilderForProductList(paramMap)); 150 searchParam.setQuery(searchServiceHelper.constructQueryBuilderForProductList(paramMap));
152 searchParam.setFiter(searchServiceHelper.constructFilterBuilder(paramMap, null)); 151 searchParam.setFiter(searchServiceHelper.constructFilterBuilder(paramMap, null));