|
|
@@ -67,14 +67,6 @@ public class TabService {
|
|
|
Set<String> tabs = new HashSet<>();
|
|
|
|
|
|
List<TabProto> personalizationTabs = this.personalizationTab(tabParam, tabs);
|
|
|
-
|
|
|
- String invalidTabCacheKey = String.format(userInvalidTabCache, tabParam.getUnionId());
|
|
|
- Set<String> invalidTabCache = Optional.ofNullable(redisTemplate.opsForSet().members(invalidTabCacheKey)).orElse(new HashSet<>());
|
|
|
- personalizationTabs = personalizationTabs.stream()
|
|
|
- .filter(i -> !invalidTabCache.contains(i.getKey()))
|
|
|
- .limit(Math.min(personalizationTabs.size(), personalizationTabSize))
|
|
|
- .collect(Collectors.toList());
|
|
|
-
|
|
|
tabProtos.addAll(this.territoryTab(tabParam, tabs));
|
|
|
tabProtos.addAll(personalizationTabs);
|
|
|
|
|
|
@@ -122,10 +114,10 @@ public class TabService {
|
|
|
|
|
|
log.info("tabCollect: {}", JSON.toJSONString(tabCollect));
|
|
|
|
|
|
- List<TabProto> profileTab = this.buildTabProto(tabCollect.get(0), TabSource.profile, TabType.personalization, tabs);
|
|
|
- List<TabProto> shareCate2Tab = this.buildTabProto(tabCollect.get(1), TabSource.share_cate2, TabType.personalization, tabs);
|
|
|
- List<TabProto> returnCate2Tab = this.buildTabProto(tabCollect.get(2), TabSource.return_cate2, TabType.personalization, tabs);
|
|
|
- List<TabProto> defaultHotTab = this.buildTabProto(tabCollect.get(3), TabSource.default_hot, TabType.personalization, tabs);
|
|
|
+ List<TabProto> profileTab = this.buildTabProto(tabCollect.get(0), tabParam.getUnionId(), TabSource.profile, TabType.personalization, tabs);
|
|
|
+ List<TabProto> shareCate2Tab = this.buildTabProto(tabCollect.get(1), tabParam.getUnionId(), TabSource.share_cate2, TabType.personalization, tabs);
|
|
|
+ List<TabProto> returnCate2Tab = this.buildTabProto(tabCollect.get(2), tabParam.getUnionId(), TabSource.return_cate2, TabType.personalization, tabs);
|
|
|
+ List<TabProto> defaultHotTab = this.buildTabProto(tabCollect.get(3), tabParam.getUnionId(), TabSource.default_hot, TabType.personalization, tabs);
|
|
|
|
|
|
// 默认兜底Tab
|
|
|
tabProtos.addAll(0, defaultHotTab);
|
|
|
@@ -135,16 +127,20 @@ public class TabService {
|
|
|
return tabProtos;
|
|
|
}
|
|
|
|
|
|
- private List<TabProto> buildTabProto(List<String> tabNames, TabSource source, TabType type, Set<String> tabs) {
|
|
|
+ private List<TabProto> buildTabProto(List<String> tabNames, String unionId, TabSource source, TabType type, Set<String> tabs) {
|
|
|
if (CollectionUtils.isEmpty(tabNames)) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ String invalidTabCacheKey = String.format(userInvalidTabCache, unionId);
|
|
|
+ Set<String> invalidTabCache = Optional.ofNullable(redisTemplate.opsForSet().members(invalidTabCacheKey)).orElse(new HashSet<>());
|
|
|
+
|
|
|
List<TabProto> tabProtos = new ArrayList<>();
|
|
|
for (String tabName : tabNames) {
|
|
|
- if (StringUtils.isBlank(tabName)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (tabs.contains(tabName)) {
|
|
|
+ if (StringUtils.isBlank(tabName)
|
|
|
+ || tabs.contains(tabName)
|
|
|
+ || invalidTabCache.contains(tabName)) {
|
|
|
continue;
|
|
|
}
|
|
|
tabProtos.add(
|