Authored by 胡古飞

抽取isProductList至controller

... ... @@ -29,6 +29,7 @@ public class ProductListController {
@ResponseBody
public SearchApiResult productList(HttpServletRequest request) {
Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
paramMap.put("isProductList", "Y");// 加个参数,表明是商品列表
return productListService.productList(paramMap);
}
... ... @@ -41,6 +42,7 @@ public class ProductListController {
@ResponseBody
public SearchApiResult getESDsl(HttpServletRequest request) {
Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
paramMap.put("isProductList", "Y");// 加个参数,表明是商品列表
return productListService.getESDsl(paramMap);
}
... ...
... ... @@ -138,8 +138,8 @@ public class SearchServiceHelper {
}
private boolean isNeedDeScoreBrandSearch(Map<String, String> paramMap) {
//如果品牌降分总开关未开启,则直接返回
if(!dynamicConfig.deScoreBrandOpen()){
// 如果品牌降分总开关未开启,则直接返回
if (!dynamicConfig.deScoreBrandOpen()) {
return false;
}
// 如果是按售价或者折扣排序或品牌也或店铺页,则降分不生效
... ... @@ -294,17 +294,17 @@ public class SearchServiceHelper {
if (StringUtils.isBlank(keyword)) {
return QueryBuilders.matchAllQuery();
}
//0、处理is_encode的情况,编码转换
String is_encode = paramMap.get("is_encode");
if(StringUtils.isNotBlank(is_encode)&&is_encode.equals("1")){
try {
keyword = URLDecoder.decode(keyword, "UTF-8");
} catch (UnsupportedEncodingException e) {
logger.warn(e.getMessage(),e);
}
}
paramMap.put("query", keyword);
// 0、处理is_encode的情况,编码转换
String is_encode = paramMap.get("is_encode");
if (StringUtils.isNotBlank(is_encode) && is_encode.equals("1")) {
try {
keyword = URLDecoder.decode(keyword, "UTF-8");
} catch (UnsupportedEncodingException e) {
logger.warn(e.getMessage(), e);
}
}
paramMap.put("query", keyword);
// 1、处理查询中包含性别的情况
this.dealKeywordOfGender(keyword, paramMap);
... ... @@ -372,15 +372,12 @@ public class SearchServiceHelper {
queryBuilder = this.buildPersonalSearch(queryBuilder, paramMap);
String dynamicRuleValue = dynamicSearchRuleHelper.getDynamicRuleValue(paramMap);
if(StringUtils.isEmpty(dynamicRuleValue) || "-1".equals(dynamicRuleValue))
{
if (StringUtils.isEmpty(dynamicRuleValue) || "-1".equals(dynamicRuleValue)) {
queryBuilder = this.buildDeScoreBrandSearch(queryBuilder, paramMap);
queryBuilder = this.buildGlobalSearch(queryBuilder, paramMap);
}
else {
} else {
queryBuilder = dynamicSearchRuleHelper.buildDynamicSerach(queryBuilder, paramMap, dynamicRuleValue);
}
return queryBuilder;
}
... ... @@ -513,7 +510,7 @@ public class SearchServiceHelper {
*/
public void setDefaultSearchField(MultiMatchQueryBuilder queryBuilder, Map<String, String> paramMap) {
List<String> fields = dynamicSearchRuleHelper.getDynamicSearchFields(paramMap);
if(CollectionUtils.isEmpty(fields)){
if (CollectionUtils.isEmpty(fields)) {
fields = ISearchConstants.SEARCH_DEFAULT_FIELD;
}
... ... @@ -604,7 +601,7 @@ public class SearchServiceHelper {
if ("Y".equals(paramMap.get(SearchRequestParams.PARAM_SEARCH_GLOBAL_FILTER_BRAND))) {
boolFilter.mustNot(QueryBuilders.termQuery("isForbiddenSortBrand", 1));
}
// 店铺
if (paramMap.containsKey(SearchRequestParams.PARAM_SEARCH_SHOP) && StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_SHOP))
&& !SearchRequestParams.PARAM_SEARCH_SHOP.equals(filterParamName)) {
... ...
... ... @@ -146,7 +146,6 @@ public class ProductListServiceImpl implements IProductListService {
}
// 2)构建基本查询参数
paramMap.put("isProductList", "Y");// 加个参数,表明是商品列表
SearchParam searchParam = new SearchParam();
searchParam.setQuery(searchServiceHelper.constructQueryBuilderForProductList(paramMap));
searchParam.setFiter(searchServiceHelper.constructFilterBuilder(paramMap, null));
... ...