Authored by hugufei

拆包

Showing 19 changed files with 132 additions and 89 deletions
... ... @@ -5,7 +5,8 @@ import com.yoho.search.aop.downgrade.PersionalRateLimit;
import com.yoho.search.common.utils.HttpServletRequestUtils;
import com.yoho.search.models.SearchApiResult;
import com.yoho.search.service.scene.list.ProductListSwitchService;
import com.yoho.search.service.scene.guang.ProductListService;
import com.yoho.search.service.scene.guang.ProductListWithPhraseService;
import com.yoho.search.service.scene.tools.ProductListDslService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
... ... @@ -21,7 +22,7 @@ import java.util.Map;
public class ProductListController {
@Autowired
private ProductListService productListService;
private ProductListWithPhraseService productListWithPhraseService;
@Autowired
private ProductListSwitchService productListSwitchService;
... ... @@ -61,7 +62,7 @@ public class ProductListController {
public SearchApiResult productListWithPhrase(HttpServletRequest request) {
Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
paramMap.remove("uid");
return productListService.productListWithPhrase(paramMap);
return productListWithPhraseService.productListWithPhrase(paramMap);
}
private Map<String, String> getParamMap(JSONObject param) {
... ... @@ -77,16 +78,4 @@ public class ProductListController {
return paramMap;
}
/**
* 打印获取商品列表的ES的dsl的工具接口
*
* @return
*/
@RequestMapping(method = RequestMethod.GET, value = "/dsl/productList")
@ResponseBody
public SearchApiResult getESDsl(HttpServletRequest request) {
Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
return productListService.getESDsl(paramMap);
}
}
... ...
package com.yoho.search.restapi.tools;
import com.yoho.search.common.utils.HttpServletRequestUtils;
import com.yoho.search.models.SearchApiResult;
import com.yoho.search.service.scene.tools.ProductListDslService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
@RestController
public class ProductListDslController {
@Autowired
private ProductListDslService productListDslService;
/**
* 打印获取商品列表的ES的dsl的工具接口
*
* @return
*/
@RequestMapping(method = RequestMethod.GET, value = "/dsl/productList")
@ResponseBody
public SearchApiResult getESDsl(HttpServletRequest request) {
Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
return productListDslService.getESDsl(paramMap);
}
}
... ...
... ... @@ -6,8 +6,8 @@ import com.yoho.search.models.SearchApiResult;
import com.yoho.search.common.SearchRequestParams;
import com.yoho.search.service.scene.list.ProductListSwitchService;
import com.yoho.search.service.scene.common.AbstractSceneService;
import com.yoho.search.service.scene.common.SceneRecommendBrandsService;
import com.yoho.search.service.scene.common.SceneSelectionsService;
import com.yoho.search.service.scene.brandshop.RecommendBrandsService;
import com.yoho.search.service.scene.aggregations.SceneSelectionsService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -26,7 +26,7 @@ public class BrandSceneService extends AbstractSceneService {
@Autowired
private SceneSelectionsService sceneSelectionsService;
@Autowired
private SceneRecommendBrandsService sceneRecommendBrandsService;
private RecommendBrandsService recommendBrandsService;
@Override
public String pageId() {
... ... @@ -66,7 +66,7 @@ public class BrandSceneService extends AbstractSceneService {
this.addParamsToParamMap(paramMap);
// 2、返回聚合结果
SearchApiResult result = sceneSelectionsService.aggregations(paramMap);
sceneRecommendBrandsService.getRecommendBrands(paramMap, result);
recommendBrandsService.getRecommendBrands(paramMap, result);
return result;
} catch (Exception e) {
logger.error("[func=BrandAggregations][params=" + paramMap + "]", e);
... ...
... ... @@ -18,8 +18,8 @@ import com.yoho.search.service.index.SizeIndexBaseService;
import com.yoho.search.service.helper.SearchParamHelper;
import com.yoho.search.service.scene.list.ProductListSwitchService;
import com.yoho.search.service.scene.common.AbstractSceneService;
import com.yoho.search.service.scene.common.SceneRecommendBrandsService;
import com.yoho.search.service.scene.common.SceneSelectionsService;
import com.yoho.search.service.scene.brandshop.RecommendBrandsService;
import com.yoho.search.service.scene.aggregations.SceneSelectionsService;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
import org.elasticsearch.search.aggregations.Aggregation;
... ... @@ -53,7 +53,7 @@ public class BreakSizeSceneService extends AbstractSceneService {
@Autowired
private SceneSelectionsService sceneSelectionsService;
@Autowired
private SceneRecommendBrandsService sceneRecommendBrandsService;
private RecommendBrandsService recommendBrandsService;
/**
* 为断码区添加默认的过滤条件
... ... @@ -92,7 +92,7 @@ public class BreakSizeSceneService extends AbstractSceneService {
// 2、返回聚合结果
List<IAggregation> aggregation = sceneSelectionsService.getBreakSizeAggregations(paramMap);
SearchApiResult result = sceneSelectionsService.aggregations(paramMap, aggregation);
sceneRecommendBrandsService.getRecommendBrands(paramMap, result);
recommendBrandsService.getRecommendBrands(paramMap, result);
return result;
} catch (Exception e) {
logger.error("[func=Couponaggregations][params=" + paramMap + "]", e);
... ...
... ... @@ -8,8 +8,8 @@ import com.yoho.search.service.scene.img.SknImgsResponse;
import com.yoho.search.common.SearchRequestParams;
import com.yoho.search.service.scene.list.ProductListSwitchService;
import com.yoho.search.service.scene.common.AbstractSceneService;
import com.yoho.search.service.scene.common.SceneRecommendBrandsService;
import com.yoho.search.service.scene.common.SceneSelectionsService;
import com.yoho.search.service.scene.brandshop.RecommendBrandsService;
import com.yoho.search.service.scene.aggregations.SceneSelectionsService;
import com.yoho.search.service.scene.img.SknImgsCacheBean;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -30,7 +30,7 @@ public class CommonSceneService extends AbstractSceneService {
@Autowired
private SceneSelectionsService sceneSelectionsService;
@Autowired
private SceneRecommendBrandsService sceneRecommendBrandsService;
private RecommendBrandsService recommendBrandsService;
@Autowired
private SknImgsCacheBean sknImgsCacheBean;
... ... @@ -64,7 +64,7 @@ public class CommonSceneService extends AbstractSceneService {
this.addParamsToParamMap(paramMap);
// 2、返回聚合结果
SearchApiResult result = sceneSelectionsService.aggregations(paramMap);
sceneRecommendBrandsService.getRecommendBrands(paramMap, result);
recommendBrandsService.getRecommendBrands(paramMap, result);
return result;
} catch (Exception e) {
logger.error("[func=Couponaggregations][params=" + paramMap + "]", e);
... ...
... ... @@ -5,8 +5,8 @@ import com.yoho.search.common.utils.SearchApiResultUtils;
import com.yoho.search.models.SearchApiResult;
import com.yoho.search.service.scene.list.ProductListSwitchService;
import com.yoho.search.service.scene.common.AbstractSceneService;
import com.yoho.search.service.scene.common.SceneRecommendBrandsService;
import com.yoho.search.service.scene.common.SceneSelectionsService;
import com.yoho.search.service.scene.brandshop.RecommendBrandsService;
import com.yoho.search.service.scene.aggregations.SceneSelectionsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -24,7 +24,7 @@ public class CouponSceneService extends AbstractSceneService {
@Autowired
private SceneSelectionsService sceneSelectionsService;
@Autowired
private SceneRecommendBrandsService sceneRecommendBrandsService;
private RecommendBrandsService recommendBrandsService;
@Override
public String pageId() {
... ... @@ -57,7 +57,7 @@ public class CouponSceneService extends AbstractSceneService {
this.addParamsToParamMap(paramMap);
// 2、返回聚合结果
SearchApiResult result = sceneSelectionsService.aggregations(paramMap);
sceneRecommendBrandsService.getRecommendBrands(paramMap, result);
recommendBrandsService.getRecommendBrands(paramMap, result);
return result;
} catch (Exception e) {
logger.error("[func=Couponaggregations][params=" + paramMap + "]", e);
... ...
... ... @@ -4,7 +4,7 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import com.yoho.search.service.scene.common.SceneRecommendBrandsService;
import com.yoho.search.service.scene.brandshop.RecommendBrandsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -18,7 +18,7 @@ import com.yoho.search.models.SearchApiResult;
import com.yoho.search.common.SearchRequestParams;
import com.yoho.search.service.scene.common.AbstractSceneService;
import com.yoho.search.service.scene.list.ProductListSwitchService;
import com.yoho.search.service.scene.common.SceneSelectionsService;
import com.yoho.search.service.scene.aggregations.SceneSelectionsService;
@Service
public class NewArrivalSceneService extends AbstractSceneService {
... ... @@ -30,7 +30,7 @@ public class NewArrivalSceneService extends AbstractSceneService {
@Autowired
private SceneSelectionsService sceneSelectionsService;
@Autowired
private SceneRecommendBrandsService sceneRecommendBrandsService;
private RecommendBrandsService recommendBrandsService;
@Override
public String pageId() {
... ... @@ -66,7 +66,7 @@ public class NewArrivalSceneService extends AbstractSceneService {
this.addParamsToParamMap(paramMap);
// 2、返回聚合结果
SearchApiResult result = sceneSelectionsService.aggregations(paramMap);
sceneRecommendBrandsService.getRecommendBrands(paramMap, result);
recommendBrandsService.getRecommendBrands(paramMap, result);
return result;
} catch (Exception e) {
logger.error("[func=NewArrivalAggregations][params=" + paramMap + "]", e);
... ...
... ... @@ -2,7 +2,7 @@ package com.yoho.search.service.scene;
import java.util.Map;
import com.yoho.search.service.scene.common.SceneRecommendBrandsService;
import com.yoho.search.service.scene.brandshop.RecommendBrandsService;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -15,7 +15,7 @@ import com.yoho.search.models.SearchApiResult;
import com.yoho.search.common.SearchRequestParams;
import com.yoho.search.service.scene.common.AbstractSceneService;
import com.yoho.search.service.scene.list.ProductListSwitchService;
import com.yoho.search.service.scene.common.SceneSelectionsService;
import com.yoho.search.service.scene.aggregations.SceneSelectionsService;
@Service
public class ProductPoolSceneService extends AbstractSceneService {
... ... @@ -27,7 +27,7 @@ public class ProductPoolSceneService extends AbstractSceneService {
@Autowired
private SceneSelectionsService sceneSelectionsService;
@Autowired
private SceneRecommendBrandsService sceneRecommendBrandsService;
private RecommendBrandsService recommendBrandsService;
/**
*
... ... @@ -91,7 +91,7 @@ public class ProductPoolSceneService extends AbstractSceneService {
try {
this.addParamsToParamMap(paramMap);
SearchApiResult result = sceneSelectionsService.aggregations(paramMap);
sceneRecommendBrandsService.getRecommendBrands(paramMap, result);
recommendBrandsService.getRecommendBrands(paramMap, result);
return result;
} catch (Exception e) {
logger.error("[func=PoolAggregations][params=" + paramMap + "]", e);
... ...
... ... @@ -17,7 +17,7 @@ import com.yoho.search.models.SearchApiResult;
import com.yoho.search.common.SearchRequestParams;
import com.yoho.search.service.scene.common.AbstractSceneService;
import com.yoho.search.service.scene.list.ProductListSwitchService;
import com.yoho.search.service.scene.common.SceneSelectionsService;
import com.yoho.search.service.scene.aggregations.SceneSelectionsService;
@Service
public class ReducePriceSceneService extends AbstractSceneService {
... ...
... ... @@ -3,7 +3,7 @@ package com.yoho.search.service.scene;
import java.util.List;
import java.util.Map;
import com.yoho.search.service.scene.common.SceneRecommendBrandsService;
import com.yoho.search.service.scene.brandshop.RecommendBrandsService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -17,7 +17,7 @@ import com.yoho.search.models.SearchApiResult;
import com.yoho.search.common.SearchRequestParams;
import com.yoho.search.service.scene.common.AbstractSceneService;
import com.yoho.search.service.scene.list.ProductListSwitchService;
import com.yoho.search.service.scene.common.SceneSelectionsService;
import com.yoho.search.service.scene.aggregations.SceneSelectionsService;
@Service
public class ShopSceneService extends AbstractSceneService {
... ... @@ -29,7 +29,7 @@ public class ShopSceneService extends AbstractSceneService {
@Autowired
private SceneSelectionsService sceneSelectionsService;
@Autowired
private SceneRecommendBrandsService sceneRecommendBrandsService;
private RecommendBrandsService recommendBrandsService;
@Override
public String pageId() {
... ... @@ -69,7 +69,7 @@ public class ShopSceneService extends AbstractSceneService {
this.addParamsToParamMap(paramMap);
// 2、返回聚合结果
SearchApiResult result = sceneSelectionsService.aggregations(paramMap);
sceneRecommendBrandsService.getRecommendBrands(paramMap, result);
recommendBrandsService.getRecommendBrands(paramMap, result);
return result;
} catch (Exception e) {
logger.error("[func=ShopAggregations][params=" + paramMap + "]", e);
... ...
... ... @@ -7,8 +7,8 @@ import com.yoho.search.common.SearchRequestParams;
import com.yoho.search.service.scene.list.ProductListSwitchService;
import com.yoho.search.service.scene.aggregations.SceneAggregationsHelper;
import com.yoho.search.service.scene.common.AbstractSceneService;
import com.yoho.search.service.scene.common.SceneRecommendBrandsService;
import com.yoho.search.service.scene.common.SceneSelectionsService;
import com.yoho.search.service.scene.brandshop.RecommendBrandsService;
import com.yoho.search.service.scene.aggregations.SceneSelectionsService;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -32,7 +32,7 @@ public class SortSceneService extends AbstractSceneService {
@Autowired
private SceneAggregationsHelper sceneAggregationsHelper;
@Autowired
private SceneRecommendBrandsService sceneRecommendBrandsService;
private RecommendBrandsService recommendBrandsService;
@Override
public String pageId() {
... ... @@ -112,7 +112,7 @@ public class SortSceneService extends AbstractSceneService {
this.addParamsToParamMap(paramMap);
// 2、返回聚合结果
SearchApiResult result = sceneSelectionsService.aggregations(paramMap);
sceneRecommendBrandsService.getRecommendBrands(paramMap, result);
recommendBrandsService.getRecommendBrands(paramMap, result);
return result;
} catch (Exception e) {
logger.error(e.getMessage(), e);
... ...
... ... @@ -2,7 +2,7 @@ package com.yoho.search.service.scene;
import java.util.Map;
import com.yoho.search.service.scene.common.SceneRecommendBrandsService;
import com.yoho.search.service.scene.brandshop.RecommendBrandsService;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -15,7 +15,7 @@ import com.yoho.search.models.SearchApiResult;
import com.yoho.search.common.SearchRequestParams;
import com.yoho.search.service.scene.common.AbstractSceneService;
import com.yoho.search.service.scene.list.ProductListSwitchService;
import com.yoho.search.service.scene.common.SceneSelectionsService;
import com.yoho.search.service.scene.aggregations.SceneSelectionsService;
@Service
public class ZqSceneService extends AbstractSceneService {
... ... @@ -27,7 +27,7 @@ public class ZqSceneService extends AbstractSceneService {
@Autowired
private SceneSelectionsService sceneSelectionsService;
@Autowired
private SceneRecommendBrandsService sceneRecommendBrandsService;
private RecommendBrandsService recommendBrandsService;
@Override
public String pageId() {
... ... @@ -67,7 +67,7 @@ public class ZqSceneService extends AbstractSceneService {
this.addParamsToParamMap(paramMap);
// 2、返回聚合结果
SearchApiResult result = sceneSelectionsService.aggregations(paramMap);
sceneRecommendBrandsService.getRecommendBrands(paramMap, result);
recommendBrandsService.getRecommendBrands(paramMap, result);
return result;
} catch (Exception e) {
logger.error("[func=zqProductList][params=" + paramMap + "]", e);
... ...
package com.yoho.search.service.scene.common;
package com.yoho.search.service.scene.aggregations;
import com.alibaba.fastjson.JSONObject;
import com.yoho.search.base.utils.ISearchConstants;
... ...
package com.yoho.search.service.scene.common;
package com.yoho.search.service.scene.brandshop;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
... ... @@ -19,7 +19,7 @@ import java.util.function.Function;
import java.util.stream.Collectors;
@Service
public class SceneRecommendBrandsService {
public class RecommendBrandsService {
@Autowired
private UserPersionalFactorComponent userPersionalFactorComponent;
... ...
... ... @@ -11,8 +11,8 @@ import com.yoho.search.service.helper.SearchKeyWordHelper;
import com.yoho.search.service.scene.list.ProductListSwitchService;
import com.yoho.search.service.scene.aggregations.SceneAggregationsHelper;
import com.yoho.search.service.scene.common.AbstractSceneService;
import com.yoho.search.service.scene.common.SceneRecommendBrandsService;
import com.yoho.search.service.scene.common.SceneSelectionsService;
import com.yoho.search.service.scene.brandshop.RecommendBrandsService;
import com.yoho.search.service.scene.aggregations.SceneSelectionsService;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -42,7 +42,7 @@ public class FuzzySceneService extends AbstractSceneService {
@Autowired
private SceneAggregationsHelper sceneAggregationsHelper;
@Autowired
private SceneRecommendBrandsService sceneRecommendBrandsService;
private RecommendBrandsService recommendBrandsService;
@Autowired
private ProductListSwitchService productListSwitchService;
... ... @@ -118,7 +118,7 @@ public class FuzzySceneService extends AbstractSceneService {
this.addParamsToParamMap(paramMap);
// 2、返回聚合结果
SearchApiResult result = sceneSelectionsService.aggregations(paramMap);
sceneRecommendBrandsService.getRecommendBrands(paramMap, result);
recommendBrandsService.getRecommendBrands(paramMap, result);
return result;
} catch (Exception e) {
logger.error(e.getMessage(), e);
... ...
package com.yoho.search.service.scene.guang;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yoho.search.aop.cache.SearchCacheAble;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.common.SearchCommonService;
import com.yoho.search.common.utils.SearchApiResultUtils;
import com.yoho.search.core.es.model.SearchParam;
import com.yoho.search.core.es.model.SearchResult;
import com.yoho.search.core.es.utils.SearchParamUtils;
import com.yoho.search.models.SearchApiResult;
import com.yoho.search.service.recall.beans.strategy.NotRecallTypeEnum;
import com.yoho.search.common.SearchCommonService;
import com.yoho.search.service.helper.ProductListHelper;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import com.yoho.search.service.recall.beans.strategy.NotRecallTypeEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -21,30 +18,15 @@ import org.springframework.stereotype.Service;
import java.util.Map;
@Service
public class ProductListService {
public class ProductListWithPhraseService {
private static final Logger logger = LoggerFactory.getLogger(ProductListService.class);
private static final Logger logger = LoggerFactory.getLogger(ProductListWithPhraseService.class);
@Autowired
private SearchCommonService searchCommonService;
@Autowired
private ProductListHelper productListHelper;
public SearchApiResult getESDsl(Map<String, String> paramMap) {
logger.info("[func=getESDsl][param={}]", paramMap);
try {
SearchParam searchParam = productListHelper.buildProductListSearchParam(paramMap, true);
SearchSourceBuilder searchSourceBuilder = SearchParamUtils.genSearchSourceBuilderFromSearchParam(searchParam);
SearchApiResult searchApiResult = new SearchApiResult();
String results = searchSourceBuilder.toString();
searchApiResult.setData(JSON.parseObject(results));
logger.info("[func=getESDsl][dsl=\n{}]", searchApiResult.getData());
return searchApiResult;
} catch (Exception e) {
return SearchApiResultUtils.errorSearchApiResult("getESDsl", paramMap, e);
}
}
@SearchCacheAble(cacheInMinute = 10, cacheName = "PRODUCT_LIST_WITH_PHRASE")
public SearchApiResult productListWithPhrase(Map<String, String> paramMap) {
try {
... ...
... ... @@ -10,8 +10,8 @@ import com.yoho.search.service.helper.SearchKeyWordHelper;
import com.yoho.search.service.scene.list.ProductListSwitchService;
import com.yoho.search.service.scene.fuzzy.FuzzySceneService;
import com.yoho.search.service.scene.common.AbstractSceneService;
import com.yoho.search.service.scene.common.SceneRecommendBrandsService;
import com.yoho.search.service.scene.common.SceneSelectionsService;
import com.yoho.search.service.scene.brandshop.RecommendBrandsService;
import com.yoho.search.service.scene.aggregations.SceneSelectionsService;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -34,7 +34,7 @@ public class MiniappFuzzySceneService extends AbstractSceneService {
@Autowired
private SceneSelectionsService sceneSelectionsService;
@Autowired
private SceneRecommendBrandsService sceneRecommendBrandsService;
private RecommendBrandsService recommendBrandsService;
@Autowired
private ProductListSwitchService productListSwitchService;
... ... @@ -96,7 +96,7 @@ public class MiniappFuzzySceneService extends AbstractSceneService {
// 2、返回聚合结果
SearchApiResult result = sceneSelectionsService.aggregations(paramMap);
if(result!=null){
sceneRecommendBrandsService.getRecommendBrands(paramMap, result);
recommendBrandsService.getRecommendBrands(paramMap, result);
}
return result;
} catch (Exception e) {
... ...
... ... @@ -7,7 +7,7 @@ import java.util.Map;
import com.yoho.search.base.utils.CollectionUtils;
import com.yoho.search.models.RecommendPromotionAggVO;
import com.yoho.search.service.scene.aggregations.SceneAggregationsHelper;
import com.yoho.search.service.scene.common.SceneRecommendBrandsService;
import com.yoho.search.service.scene.brandshop.RecommendBrandsService;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
import org.elasticsearch.search.aggregations.Aggregation;
... ... @@ -31,7 +31,7 @@ import com.yoho.search.common.SearchCommonService;
import com.yoho.search.service.helper.SearchAfterCacheHelper;
import com.yoho.search.service.helper.SearchParamHelper;
import com.yoho.search.cache.beans.AbstractCacheAbleService;
import com.yoho.search.service.scene.common.SceneSelectionsService;
import com.yoho.search.service.scene.aggregations.SceneSelectionsService;
import com.yoho.search.service.scene.brandshop.BrandService;
import com.yoho.search.service.scene.aggregations.DiscountService;
import com.yoho.search.service.scene.aggregations.SearchSortGroupService;
... ... @@ -66,7 +66,7 @@ public class PromotionAggregationsService extends AbstractCacheAbleService {
@Autowired
private PromotionSceneHelper promotionSceneHelper;
@Autowired
private SceneRecommendBrandsService sceneRecommendBrandsService;
private RecommendBrandsService recommendBrandsService;
@Autowired
private SceneAggregationsHelper sceneAggregationsHelper;
... ... @@ -196,7 +196,7 @@ public class PromotionAggregationsService extends AbstractCacheAbleService {
// 0、解析promotion的限制条件
BoolQueryBuilder mustFilter = promotionSceneHelper.getMustFilterByPromotion(promotionConditions);
SearchApiResult result = sceneSelectionsService.aggregations(paramMap, mustFilter);
sceneRecommendBrandsService.getRecommendBrands(paramMap, result);
recommendBrandsService.getRecommendBrands(paramMap, result);
return result;
} catch (Exception e) {
logger.error(e.getMessage(), e);
... ...
package com.yoho.search.service.scene.tools;
import com.alibaba.fastjson.JSON;
import com.yoho.search.common.utils.SearchApiResultUtils;
import com.yoho.search.core.es.model.SearchParam;
import com.yoho.search.core.es.utils.SearchParamUtils;
import com.yoho.search.models.SearchApiResult;
import com.yoho.search.service.helper.ProductListHelper;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
@Service
public class ProductListDslService {
private static final Logger logger = LoggerFactory.getLogger(ProductListDslService.class);
@Autowired
private ProductListHelper productListHelper;
public SearchApiResult getESDsl(Map<String, String> paramMap) {
logger.info("[func=getESDsl][param={}]", paramMap);
try {
SearchParam searchParam = productListHelper.buildProductListSearchParam(paramMap, true);
SearchSourceBuilder searchSourceBuilder = SearchParamUtils.genSearchSourceBuilderFromSearchParam(searchParam);
SearchApiResult searchApiResult = new SearchApiResult();
String results = searchSourceBuilder.toString();
searchApiResult.setData(JSON.parseObject(results));
logger.info("[func=getESDsl][dsl=\n{}]", searchApiResult.getData());
return searchApiResult;
} catch (Exception e) {
return SearchApiResultUtils.errorSearchApiResult("getESDsl", paramMap, e);
}
}
}
... ...