Showing
13 changed files
with
211 additions
and
22 deletions
1 | +package com.yoho.search.restapi.scene; | ||
2 | + | ||
3 | +import com.yoho.search.aop.downgrade.PersionalRateLimit; | ||
4 | +import com.yoho.search.common.utils.HttpServletRequestUtils; | ||
5 | +import com.yoho.search.models.SearchApiResult; | ||
6 | +import com.yoho.search.service.scene.pages.FirstPageSceneService; | ||
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 javax.servlet.http.HttpServletRequest; | ||
14 | +import java.util.Map; | ||
15 | + | ||
16 | +/** | ||
17 | + * 首页-猜你喜欢个性化接口 | ||
18 | + * | ||
19 | + * @author gufei.hu | ||
20 | + */ | ||
21 | +@Controller | ||
22 | +public class FirstPageSceneController { | ||
23 | + | ||
24 | + @Autowired | ||
25 | + private FirstPageSceneService firstPageSceneService; | ||
26 | + | ||
27 | + /** | ||
28 | + * 首页-猜你喜欢个性化接口 | ||
29 | + * | ||
30 | + * @return | ||
31 | + */ | ||
32 | + @PersionalRateLimit(isOrderUseable = true) | ||
33 | + @RequestMapping(method = RequestMethod.GET, value = "/firstPage/productList") | ||
34 | + @ResponseBody | ||
35 | + public SearchApiResult firstPageProductList(HttpServletRequest request) { | ||
36 | + Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request); | ||
37 | + return firstPageSceneService.productList(paramMap); | ||
38 | + } | ||
39 | + | ||
40 | +} |
@@ -21,7 +21,8 @@ import com.yoho.search.models.SearchApiResult; | @@ -21,7 +21,8 @@ import com.yoho.search.models.SearchApiResult; | ||
21 | import com.yoho.search.service.scene.shopbrand.BrandListService; | 21 | import com.yoho.search.service.scene.shopbrand.BrandListService; |
22 | 22 | ||
23 | @Controller | 23 | @Controller |
24 | -public class BrandController { | 24 | +public class |
25 | +BrandController { | ||
25 | 26 | ||
26 | @Autowired | 27 | @Autowired |
27 | private BrandListService brandListService; | 28 | private BrandListService brandListService; |
@@ -32,11 +32,13 @@ public class CommonRecallRequestBuilder { | @@ -32,11 +32,13 @@ public class CommonRecallRequestBuilder { | ||
32 | requests.add(this.buildFirstSknRequest(userRecallRequest, firstProductSkns)); | 32 | requests.add(this.buildFirstSknRequest(userRecallRequest, firstProductSkns)); |
33 | //1.2) 直通车召回 | 33 | //1.2) 直通车召回 |
34 | requests.add(this.buildDirectTrainRequest(userRecallRequest)); | 34 | requests.add(this.buildDirectTrainRequest(userRecallRequest)); |
35 | - //1.3) 新开店铺的召回 | 35 | + //1.3) 直通车-ufo召回 |
36 | + requests.add(this.buildUfoDirectTrainRequest(userRecallRequest)); | ||
37 | + //1.4) 新开店铺的召回 | ||
36 | requests.add(this.buildNewShopRequest(userRecallRequest)); | 38 | requests.add(this.buildNewShopRequest(userRecallRequest)); |
37 | - //1.4) 流量补偿的召回 | 39 | + //1.5) 流量补偿的召回 |
38 | requests.add(this.buildAddFlowRequest(userRecallRequest)); | 40 | requests.add(this.buildAddFlowRequest(userRecallRequest)); |
39 | - //1.5) 页面的兜底召回 | 41 | + //1.6) 页面的兜底召回 |
40 | requests.add(this.buildCommonHeatValueStrategy(userRecallRequest, pageSize)); | 42 | requests.add(this.buildCommonHeatValueStrategy(userRecallRequest, pageSize)); |
41 | return requests; | 43 | return requests; |
42 | } | 44 | } |
@@ -60,19 +62,31 @@ public class CommonRecallRequestBuilder { | @@ -60,19 +62,31 @@ public class CommonRecallRequestBuilder { | ||
60 | * @return | 62 | * @return |
61 | */ | 63 | */ |
62 | private RecallRequest buildDirectTrainRequest(UserRecallRequest userRecallRequest) { | 64 | private RecallRequest buildDirectTrainRequest(UserRecallRequest userRecallRequest) { |
63 | - int size = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.DIRECT_TRAIN); | 65 | + int size = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.DIRECT_TRAIN,60); |
64 | CommonDirectTrainStrategy strategy = new CommonDirectTrainStrategy(size); | 66 | CommonDirectTrainStrategy strategy = new CommonDirectTrainStrategy(size); |
65 | return new RecallRequest(userRecallRequest.getParamQueryFilter(), strategy); | 67 | return new RecallRequest(userRecallRequest.getParamQueryFilter(), strategy); |
66 | } | 68 | } |
67 | 69 | ||
68 | /** | 70 | /** |
71 | + * 构建【按UFO直通车召回】的请求参数 | ||
72 | + * | ||
73 | + * @param userRecallRequest | ||
74 | + * @return | ||
75 | + */ | ||
76 | + private RecallRequest buildUfoDirectTrainRequest(UserRecallRequest userRecallRequest) { | ||
77 | + int size = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.DIRECT_TRAIN_UFO,40); | ||
78 | + CommonDirectTrainUfoStrategy strategy = new CommonDirectTrainUfoStrategy(size); | ||
79 | + return new RecallRequest(userRecallRequest.getParamQueryFilter(), strategy); | ||
80 | + } | ||
81 | + | ||
82 | + /** | ||
69 | * 构建【按新开店铺召回】的请求参数 | 83 | * 构建【按新开店铺召回】的请求参数 |
70 | * | 84 | * |
71 | * @param userRecallRequest | 85 | * @param userRecallRequest |
72 | * @return | 86 | * @return |
73 | */ | 87 | */ |
74 | private RecallRequest buildNewShopRequest(UserRecallRequest userRecallRequest) { | 88 | private RecallRequest buildNewShopRequest(UserRecallRequest userRecallRequest) { |
75 | - int size = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.NEW_SHOP); | 89 | + int size = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.NEW_SHOP,10); |
76 | CommonNewShopStrategy strategy = new CommonNewShopStrategy(size); | 90 | CommonNewShopStrategy strategy = new CommonNewShopStrategy(size); |
77 | return new RecallRequest(userRecallRequest.getParamQueryFilter(), strategy); | 91 | return new RecallRequest(userRecallRequest.getParamQueryFilter(), strategy); |
78 | } | 92 | } |
@@ -84,7 +98,7 @@ public class CommonRecallRequestBuilder { | @@ -84,7 +98,7 @@ public class CommonRecallRequestBuilder { | ||
84 | * @return | 98 | * @return |
85 | */ | 99 | */ |
86 | private RecallRequest buildAddFlowRequest(UserRecallRequest userRecallRequest) { | 100 | private RecallRequest buildAddFlowRequest(UserRecallRequest userRecallRequest) { |
87 | - int size = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.ADD_FLOW); | 101 | + int size = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.ADD_FLOW,10); |
88 | CommonAddFlowStrategy strategy = new CommonAddFlowStrategy(size); | 102 | CommonAddFlowStrategy strategy = new CommonAddFlowStrategy(size); |
89 | return new RecallRequest(userRecallRequest.getParamQueryFilter(), strategy); | 103 | return new RecallRequest(userRecallRequest.getParamQueryFilter(), strategy); |
90 | } | 104 | } |
@@ -279,7 +279,7 @@ public class UserRecallResponseBuilder { | @@ -279,7 +279,7 @@ public class UserRecallResponseBuilder { | ||
279 | // 3、占坑 | 279 | // 3、占坑 |
280 | int fromIndex = 1; | 280 | int fromIndex = 1; |
281 | for (StrategyEnum strategyEnum : intervalStrategyEnums) { | 281 | for (StrategyEnum strategyEnum : intervalStrategyEnums) { |
282 | - int recallInterval = recallConfigService.queryStrategyConfigInterval(userRecallRequest, strategyEnum); | 282 | + int recallInterval = recallConfigService.queryStrategyConfigInterval(userRecallRequest, strategyEnum,10); |
283 | this.addByIndexIndex(sknResultList, results, fromIndex++, recallInterval, (sknResult -> strategyEnum.equals(sknResult.getStrategy())), dropTransfer); | 283 | this.addByIndexIndex(sknResultList, results, fromIndex++, recallInterval, (sknResult -> strategyEnum.equals(sknResult.getStrategy())), dropTransfer); |
284 | } | 284 | } |
285 | return results; | 285 | return results; |
@@ -26,7 +26,6 @@ import com.yoho.search.service.recall.models.req.RecallRequest; | @@ -26,7 +26,6 @@ import com.yoho.search.service.recall.models.req.RecallRequest; | ||
26 | import com.yoho.search.service.recall.models.req.RecallRequestResponse; | 26 | import com.yoho.search.service.recall.models.req.RecallRequestResponse; |
27 | import com.yoho.search.service.recall.models.req.RecallResponse; | 27 | import com.yoho.search.service.recall.models.req.RecallResponse; |
28 | import com.yoho.search.service.recall.models.req.UserRecallRequest; | 28 | import com.yoho.search.service.recall.models.req.UserRecallRequest; |
29 | -import com.yoho.search.service.scene.shopbrand.RecommendBrandService; | ||
30 | import org.apache.commons.collections.MapUtils; | 29 | import org.apache.commons.collections.MapUtils; |
31 | import org.apache.commons.lang.StringUtils; | 30 | import org.apache.commons.lang.StringUtils; |
32 | import org.elasticsearch.index.query.BoolQueryBuilder; | 31 | import org.elasticsearch.index.query.BoolQueryBuilder; |
@@ -69,21 +68,21 @@ public class SknRecallCacheBean { | @@ -69,21 +68,21 @@ public class SknRecallCacheBean { | ||
69 | try { | 68 | try { |
70 | List<Integer> filterSknList = new ArrayList<>(); | 69 | List<Integer> filterSknList = new ArrayList<>(); |
71 | //1、获取实时点击skn的配置 | 70 | //1、获取实时点击skn的配置 |
72 | - int recSknCount = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.REC_SKN); | 71 | + int recSknCount = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.REC_SKN, 8); |
73 | if (recSknCount > 0 && userPersonalFactor.getRecommendSknList() != null) { | 72 | if (recSknCount > 0 && userPersonalFactor.getRecommendSknList() != null) { |
74 | filterSknList.addAll(userPersonalFactor.getRecommendSknList()); | 73 | filterSknList.addAll(userPersonalFactor.getRecommendSknList()); |
75 | } else { | 74 | } else { |
76 | recSknCount = 0; | 75 | recSknCount = 0; |
77 | } | 76 | } |
78 | //2、获取相似skn的配置 | 77 | //2、获取相似skn的配置 |
79 | - int youtubeSknCount = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.RT_YOUTUBE_SKN); | 78 | + int youtubeSknCount = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.RT_YOUTUBE_SKN, 8); |
80 | if (youtubeSknCount > 0 && userPersonalFactor.getRealTimeYoutubeSknList() != null) { | 79 | if (youtubeSknCount > 0 && userPersonalFactor.getRealTimeYoutubeSknList() != null) { |
81 | filterSknList.addAll(userPersonalFactor.getRealTimeYoutubeSknList()); | 80 | filterSknList.addAll(userPersonalFactor.getRealTimeYoutubeSknList()); |
82 | } else { | 81 | } else { |
83 | youtubeSknCount = 0; | 82 | youtubeSknCount = 0; |
84 | } | 83 | } |
85 | //3、获取相似skn的配置 | 84 | //3、获取相似skn的配置 |
86 | - int rtSimSknCount = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.RT_SIM_SKN); | 85 | + int rtSimSknCount = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.RT_SIM_SKN, 8); |
87 | if (rtSimSknCount > 0 && userPersonalFactor.getRealTimeSimilarSknList() != null) { | 86 | if (rtSimSknCount > 0 && userPersonalFactor.getRealTimeSimilarSknList() != null) { |
88 | filterSknList.addAll(userPersonalFactor.getRealTimeSimilarSknList()); | 87 | filterSknList.addAll(userPersonalFactor.getRealTimeSimilarSknList()); |
89 | } else { | 88 | } else { |
@@ -26,6 +26,7 @@ public class ExtendFilterHelper { | @@ -26,6 +26,7 @@ public class ExtendFilterHelper { | ||
26 | filter.must(QueryBuilders.termQuery(ProductIndexEsField.flowType, "1")); | 26 | filter.must(QueryBuilders.termQuery(ProductIndexEsField.flowType, "1")); |
27 | //filter.mustNot(QueryBuilders.rangeQuery(ProductIndexEsField.breakSizePercent).gt(50)); | 27 | //filter.mustNot(QueryBuilders.rangeQuery(ProductIndexEsField.breakSizePercent).gt(50)); |
28 | filter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.isGlobal, "Y")); | 28 | filter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.isGlobal, "Y")); |
29 | + filter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.isUfo, "Y")); | ||
29 | filter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.shopId, SpecialShopConstants.DOWNGRADE_SHOPIDS)); | 30 | filter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.shopId, SpecialShopConstants.DOWNGRADE_SHOPIDS)); |
30 | return filter; | 31 | return filter; |
31 | } | 32 | } |
@@ -38,7 +39,21 @@ public class ExtendFilterHelper { | @@ -38,7 +39,21 @@ public class ExtendFilterHelper { | ||
38 | public static QueryBuilder directTrainFilter() { | 39 | public static QueryBuilder directTrainFilter() { |
39 | BoolQueryBuilder filter = QueryBuilders.boolQuery(); | 40 | BoolQueryBuilder filter = QueryBuilders.boolQuery(); |
40 | filter.must(QueryBuilders.termQuery(ProductIndexEsField.toAddScore, "Y")); | 41 | filter.must(QueryBuilders.termQuery(ProductIndexEsField.toAddScore, "Y")); |
41 | - //filter.mustNot(QueryBuilders.rangeQuery(ProductIndexEsField.breakSizePercent).gt(50)); | 42 | + filter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.isUfo, "Y")); |
43 | + filter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.isGlobal, "Y")); | ||
44 | + filter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.shopId, SpecialShopConstants.DOWNGRADE_SHOPIDS)); | ||
45 | + return filter; | ||
46 | + } | ||
47 | + | ||
48 | + /** | ||
49 | + * ufo直通车的过滤器 | ||
50 | + * | ||
51 | + * @return | ||
52 | + */ | ||
53 | + public static QueryBuilder ufoDirectTrainFilter() { | ||
54 | + BoolQueryBuilder filter = QueryBuilders.boolQuery(); | ||
55 | + filter.must(QueryBuilders.termQuery(ProductIndexEsField.toAddScore, "Y")); | ||
56 | + filter.must(QueryBuilders.termQuery(ProductIndexEsField.isUfo, "Y")); | ||
42 | filter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.isGlobal, "Y")); | 57 | filter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.isGlobal, "Y")); |
43 | filter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.shopId, SpecialShopConstants.DOWNGRADE_SHOPIDS)); | 58 | filter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.shopId, SpecialShopConstants.DOWNGRADE_SHOPIDS)); |
44 | return filter; | 59 | return filter; |
@@ -223,7 +238,7 @@ public class ExtendFilterHelper { | @@ -223,7 +238,7 @@ public class ExtendFilterHelper { | ||
223 | BoolQueryBuilder filter = QueryBuilders.boolQuery(); | 238 | BoolQueryBuilder filter = QueryBuilders.boolQuery(); |
224 | filter.should(QueryBuilders.termQuery(ProductIndexEsField.flowType, "2")); | 239 | filter.should(QueryBuilders.termQuery(ProductIndexEsField.flowType, "2")); |
225 | filter.should(QueryBuilders.termQuery(ProductIndexEsField.isGlobal, "Y")); | 240 | filter.should(QueryBuilders.termQuery(ProductIndexEsField.isGlobal, "Y")); |
226 | - //filter.should(QueryBuilders.rangeQuery(ProductIndexEsField.breakSizePercent).gt(50)); | 241 | + filter.should(QueryBuilders.termQuery(ProductIndexEsField.isUfo, "Y")); |
227 | filter.should(QueryBuilders.termsQuery(ProductIndexEsField.storeShowStatus, Arrays.asList("3", "4"))); | 242 | filter.should(QueryBuilders.termsQuery(ProductIndexEsField.storeShowStatus, Arrays.asList("3", "4"))); |
228 | filter.should(QueryBuilders.termsQuery(ProductIndexEsField.shopId, SpecialShopConstants.DOWNGRADE_SHOPIDS)); | 243 | filter.should(QueryBuilders.termsQuery(ProductIndexEsField.shopId, SpecialShopConstants.DOWNGRADE_SHOPIDS)); |
229 | return filter; | 244 | return filter; |
@@ -29,11 +29,11 @@ public class StrategyHelper { | @@ -29,11 +29,11 @@ public class StrategyHelper { | ||
29 | * @return | 29 | * @return |
30 | */ | 30 | */ |
31 | public static List<StrategyEnum> getIntervalStrategyEnums() { | 31 | public static List<StrategyEnum> getIntervalStrategyEnums() { |
32 | - return Arrays.asList(StrategyEnum.REC_SKN, StrategyEnum.RT_YOUTUBE_SKN, StrategyEnum.RT_SIM_SKN, StrategyEnum.DIRECT_TRAIN, StrategyEnum.ADD_FLOW, StrategyEnum.NEW_SHOP); | 32 | + return Arrays.asList(StrategyEnum.REC_SKN, StrategyEnum.RT_YOUTUBE_SKN, StrategyEnum.RT_SIM_SKN, StrategyEnum.DIRECT_TRAIN, StrategyEnum.DIRECT_TRAIN_UFO, StrategyEnum.ADD_FLOW, StrategyEnum.NEW_SHOP); |
33 | } | 33 | } |
34 | 34 | ||
35 | /** | 35 | /** |
36 | - *推荐类型枚举 | 36 | + * 推荐类型枚举 |
37 | * | 37 | * |
38 | * @return | 38 | * @return |
39 | */ | 39 | */ |
@@ -45,7 +45,7 @@ public class StrategyHelper { | @@ -45,7 +45,7 @@ public class StrategyHelper { | ||
45 | } | 45 | } |
46 | 46 | ||
47 | /** | 47 | /** |
48 | - *按class生成IRecallSknStrategy | 48 | + * 按class生成IRecallSknStrategy |
49 | * | 49 | * |
50 | * @return | 50 | * @return |
51 | */ | 51 | */ |
@@ -72,6 +72,9 @@ public class StrategyHelper { | @@ -72,6 +72,9 @@ public class StrategyHelper { | ||
72 | if (strategyEnum.equals(StrategyEnum.DIRECT_TRAIN)) { | 72 | if (strategyEnum.equals(StrategyEnum.DIRECT_TRAIN)) { |
73 | return RecallConfigConstants.DIRECT_TRAIN; | 73 | return RecallConfigConstants.DIRECT_TRAIN; |
74 | } | 74 | } |
75 | + if (strategyEnum.equals(StrategyEnum.DIRECT_TRAIN_UFO)) { | ||
76 | + return RecallConfigConstants.DIRECT_TRAIN_UFO; | ||
77 | + } | ||
75 | if (strategyEnum.equals(StrategyEnum.NEW_SHOP)) { | 78 | if (strategyEnum.equals(StrategyEnum.NEW_SHOP)) { |
76 | return RecallConfigConstants.NEW_SHOP; | 79 | return RecallConfigConstants.NEW_SHOP; |
77 | } | 80 | } |
@@ -2,8 +2,9 @@ package com.yoho.search.service.recall.beans.strategy; | @@ -2,8 +2,9 @@ package com.yoho.search.service.recall.beans.strategy; | ||
2 | 2 | ||
3 | public enum StrategyEnum { | 3 | public enum StrategyEnum { |
4 | 4 | ||
5 | - FIRST_SKN(110),//配置的skn | ||
6 | - DIRECT_TRAIN(109),//直通车 | 5 | + FIRST_SKN(111),//配置的skn |
6 | + DIRECT_TRAIN(110),//直通车 | ||
7 | + DIRECT_TRAIN_UFO(109),//UFO直通车 | ||
7 | REC_SKN(108),//实时推荐的skn | 8 | REC_SKN(108),//实时推荐的skn |
8 | RT_YOUTUBE_SKN(107),//实时推荐的skn的相似skn | 9 | RT_YOUTUBE_SKN(107),//实时推荐的skn的相似skn |
9 | RT_SIM_SKN(106),//实时推荐的skn的相似skn | 10 | RT_SIM_SKN(106),//实时推荐的skn的相似skn |
1 | +package com.yoho.search.service.recall.beans.strategy.impls; | ||
2 | + | ||
3 | +import com.yoho.search.cache.CacheTimeConstants; | ||
4 | +import com.yoho.search.service.recall.beans.helper.ExtendFilterHelper; | ||
5 | +import com.yoho.search.service.recall.beans.helper.SortBuilderHelper; | ||
6 | +import com.yoho.search.service.recall.beans.strategy.IStrategy; | ||
7 | +import com.yoho.search.service.recall.beans.strategy.StrategyEnum; | ||
8 | +import org.elasticsearch.index.query.QueryBuilder; | ||
9 | +import org.elasticsearch.search.sort.SortBuilder; | ||
10 | + | ||
11 | +/** | ||
12 | + * 直通车的召回 | ||
13 | + * | ||
14 | + * @author gufei.hu | ||
15 | + * | ||
16 | + */ | ||
17 | +public class CommonDirectTrainUfoStrategy implements IStrategy { | ||
18 | + | ||
19 | + private int size; | ||
20 | + | ||
21 | + public CommonDirectTrainUfoStrategy(int size) { | ||
22 | + this.size = size; | ||
23 | + } | ||
24 | + | ||
25 | + @Override | ||
26 | + public StrategyEnum strategtEnum() { | ||
27 | + return StrategyEnum.DIRECT_TRAIN_UFO; | ||
28 | + } | ||
29 | + | ||
30 | + @Override | ||
31 | + public QueryBuilder extendFilter() { | ||
32 | + return ExtendFilterHelper.ufoDirectTrainFilter(); | ||
33 | + } | ||
34 | + | ||
35 | + @Override | ||
36 | + public SortBuilder<?> sortBuilder() { | ||
37 | + return SortBuilderHelper.getRandomSort(); | ||
38 | + } | ||
39 | + | ||
40 | + @Override | ||
41 | + public int size() { | ||
42 | + return size; | ||
43 | + } | ||
44 | + | ||
45 | + @Override | ||
46 | + public int cacheTimeInMinute() { | ||
47 | + return CacheTimeConstants.COMMON_RECALL_STRATEGY_CACHE_TIME; | ||
48 | + } | ||
49 | + | ||
50 | + @Override | ||
51 | + public String strategyCacheKey() { | ||
52 | + StringBuilder sb = defaultStrategyKey(); | ||
53 | + return sb.toString(); | ||
54 | + } | ||
55 | + | ||
56 | +} |
@@ -7,6 +7,7 @@ public class RecallConfigConstants { | @@ -7,6 +7,7 @@ public class RecallConfigConstants { | ||
7 | public static final int DEFAULT_PAGE_ID = 0; | 7 | public static final int DEFAULT_PAGE_ID = 0; |
8 | 8 | ||
9 | public static final String DIRECT_TRAIN = "DIRECT_TRAIN"; | 9 | public static final String DIRECT_TRAIN = "DIRECT_TRAIN"; |
10 | + public static final String DIRECT_TRAIN_UFO = "DIRECT_TRAIN_UFO"; | ||
10 | public static final String REC_SKN = "REC_SKN"; | 11 | public static final String REC_SKN = "REC_SKN"; |
11 | public static final String RT_SIM_SKN = "RT_SIM_SKN"; | 12 | public static final String RT_SIM_SKN = "RT_SIM_SKN"; |
12 | public static final String RT_YOUTUBE_SKN = "RT_YOUTUBE_SKN"; | 13 | public static final String RT_YOUTUBE_SKN = "RT_YOUTUBE_SKN"; |
@@ -40,9 +40,9 @@ public class RecallConfigService { | @@ -40,9 +40,9 @@ public class RecallConfigService { | ||
40 | * @param strategyEnum | 40 | * @param strategyEnum |
41 | * @return | 41 | * @return |
42 | */ | 42 | */ |
43 | - public int queryStrategyConfigSize(UserRecallRequest userRecallRequest, StrategyEnum strategyEnum) { | 43 | + public int queryStrategyConfigSize(UserRecallRequest userRecallRequest, StrategyEnum strategyEnum,int defaultSize) { |
44 | String configKey = StrategyHelper.getStrategyConfigKey(strategyEnum); | 44 | String configKey = StrategyHelper.getStrategyConfigKey(strategyEnum); |
45 | - int size = recallConfigCommonService.queryConfigSize(userRecallRequest.getPageId(), configKey, 0); | 45 | + int size = recallConfigCommonService.queryConfigSize(userRecallRequest.getPageId(), configKey, defaultSize); |
46 | size = this.legallValue(size, 0, 100); | 46 | size = this.legallValue(size, 0, 100); |
47 | if (userRecallRequest.openDetailLog()) { | 47 | if (userRecallRequest.openDetailLog()) { |
48 | RECALL_LOGGER.info("queryStrategyConfigSize,pageId is [{}],strategyEnum is [{}],size is[{}]", userRecallRequest.getPageId(), strategyEnum.name(), size); | 48 | RECALL_LOGGER.info("queryStrategyConfigSize,pageId is [{}],strategyEnum is [{}],size is[{}]", userRecallRequest.getPageId(), strategyEnum.name(), size); |
@@ -57,7 +57,7 @@ public class RecallConfigService { | @@ -57,7 +57,7 @@ public class RecallConfigService { | ||
57 | * @param strategyEnum | 57 | * @param strategyEnum |
58 | * @return | 58 | * @return |
59 | */ | 59 | */ |
60 | - public int queryStrategyConfigInterval(UserRecallRequest userRecallRequest, StrategyEnum strategyEnum) { | 60 | + public int queryStrategyConfigInterval(UserRecallRequest userRecallRequest, StrategyEnum strategyEnum,int defaultInterval) { |
61 | String configKey = StrategyHelper.getStrategyConfigKey(strategyEnum); | 61 | String configKey = StrategyHelper.getStrategyConfigKey(strategyEnum); |
62 | int interval = recallConfigCommonService.queryConfigInterval(userRecallRequest.getPageId(), configKey, 10); | 62 | int interval = recallConfigCommonService.queryConfigInterval(userRecallRequest.getPageId(), configKey, 10); |
63 | interval = this.legallValue(interval, 2, 40); | 63 | interval = this.legallValue(interval, 2, 40); |
1 | +package com.yoho.search.service.scene.pages; | ||
2 | + | ||
3 | +import com.alibaba.fastjson.JSONObject; | ||
4 | +import com.yoho.search.base.utils.SearchPageIdDefine; | ||
5 | +import com.yoho.search.common.utils.SearchApiResultUtils; | ||
6 | +import com.yoho.search.core.es.utils.PageUtils; | ||
7 | +import com.yoho.search.models.SearchApiResult; | ||
8 | +import com.yoho.search.service.scene.pages.entrance.ProductListSwitchService; | ||
9 | +import org.apache.commons.collections.MapUtils; | ||
10 | +import org.slf4j.Logger; | ||
11 | +import org.slf4j.LoggerFactory; | ||
12 | +import org.springframework.beans.factory.annotation.Autowired; | ||
13 | +import org.springframework.stereotype.Service; | ||
14 | + | ||
15 | +import java.util.Map; | ||
16 | + | ||
17 | +@Service | ||
18 | +public class FirstPageSceneService extends AbstractPageSceneService { | ||
19 | + | ||
20 | + private static final Logger logger = LoggerFactory.getLogger(CouponPageSceneService.class); | ||
21 | + | ||
22 | + @Autowired | ||
23 | + private ProductListSwitchService productListSwitchService; | ||
24 | + | ||
25 | + @Override | ||
26 | + public String pageId() { | ||
27 | + return SearchPageIdDefine.PAGE_ID_FIESTPAGE_GUESSLIKE; | ||
28 | + } | ||
29 | + | ||
30 | + @Override | ||
31 | + public void addParamsToParamMap(Map<String, String> paramMap) { | ||
32 | + super.addDefaultParamsToParamMap(paramMap); | ||
33 | + } | ||
34 | + | ||
35 | + @Override | ||
36 | + public SearchApiResult productList(Map<String, String> paramMap) { | ||
37 | + try { | ||
38 | + // 1、添加默认参数 | ||
39 | + this.addParamsToParamMap(paramMap); | ||
40 | + // 2、返回商品列表 | ||
41 | + SearchApiResult searchApiResult = productListSwitchService.productList(this.newParamMap(paramMap)); | ||
42 | + JSONObject jsonObject = (JSONObject) searchApiResult.getData(); | ||
43 | + // 3、限制最大返回条数为200条 | ||
44 | + long total = Math.min(MapUtils.getIntValue(jsonObject, "total", 0), 200L); | ||
45 | + int page_size = MapUtils.getIntValue(jsonObject, "page_size", 0); | ||
46 | + jsonObject.put("total", total); | ||
47 | + jsonObject.put("page_total", PageUtils.getTotalPage(total,page_size)); | ||
48 | + return searchApiResult; | ||
49 | + } catch (Exception e) { | ||
50 | + return SearchApiResultUtils.errorSearchApiResult(logger, paramMap, e); | ||
51 | + } | ||
52 | + } | ||
53 | + | ||
54 | + @Override | ||
55 | + public SearchApiResult aggregations(Map<String, String> paramMap) { | ||
56 | + return new SearchApiResult(); | ||
57 | + } | ||
58 | +} | ||
59 | + |
-
Please register or login to post a comment