Ver código fonte

feat:流量池黑名单判断添加白名单配置

zhaohaipeng 11 meses atrás
pai
commit
c11e5cc6f9

+ 8 - 11
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/RecallService.java

@@ -38,10 +38,10 @@ public class RecallService implements ApplicationContextAware {
     private BlacklistContainer blacklistContainer;
 
     /**
-     * 在流量池场景下,哪些appType用判断黑名单
+     * 在流量池场景下,哪些appType用判断黑名单
      */
-    @ApolloJsonValue("${content.security.recommendflowpool.whitelist.apptype.config:[]}")
-    private Set<Integer> contentSecurityWhitelistAppTypeSet;
+    @ApolloJsonValue("${content.security.recommendflowpool.blacklist.apptype.config:[]}")
+    private Set<Integer> blacklistAppTypeSet;
 
     @PostConstruct
     public void init() {
@@ -91,13 +91,10 @@ public class RecallService implements ApplicationContextAware {
             return strategies;
         }
 
-        // 白名单里的appType不判断黑名单
-        boolean hitUserBlacklist = false;
-        if (CollectionUtils.isEmpty(contentSecurityWhitelistAppTypeSet) || !contentSecurityWhitelistAppTypeSet.contains(param.getAppType())) {
             String matchUserBlacklistTypeEnum = blacklistContainer.matchUserBlacklistTypeEnum(param.getUid(), param.getHotSceneType(), param.getCityCode(),
                     param.getClientIp(), param.getMid(), "recommend-flow-pool", param.getAppType());
-            hitUserBlacklist = StringUtils.isNotBlank(matchUserBlacklistTypeEnum);
-        }
+        boolean hitUserBlacklist =  StringUtils.isNotBlank(matchUserBlacklistTypeEnum);
+        boolean isInBlacklist = CollectionUtils.isNotEmpty(blacklistAppTypeSet) && blacklistAppTypeSet.contains(param.getAppType());
 
         String abCode = param.getAbCode();
         //1:通过“产品”控制“召回子策略”
@@ -175,7 +172,7 @@ public class RecallService implements ApplicationContextAware {
                     strategies.addAll(getRegionRecallStrategy(param));
             }
             // 命中用户黑名单不走流量池
-            if (!hitUserBlacklist) {
+            if (!hitUserBlacklist || !isInBlacklist) {
                 //2:通过“流量池标记”控制“流量池召回子策略” 其中有9组会走EXPERIMENTAL_FLOW_SET_LEVEL 有1组会走EXPERIMENTAL_FLOW_SET_LEVEL_SCORE
                 if ("60116".equals(abCode)) {
                     int lastDigit = param.getLastDigit();
@@ -289,7 +286,7 @@ public class RecallService implements ApplicationContextAware {
                 case "60115": // 565
                 case "60117": // 567
                 case "60118": // 568
-                    if (!hitUserBlacklist) {
+                    if (!hitUserBlacklist || !isInBlacklist) {
                         strategies.add(strategyMap.get(FlowPoolLastDayTopRecallStrategy.class.getSimpleName()));
                     }
                     strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
@@ -301,7 +298,7 @@ public class RecallService implements ApplicationContextAware {
                     break;
                 case "60110": // 新内容的召回(流量池的Top内容)
                     strategies.add(strategyMap.get(TopGoodPerformanceVideoRecallStrategy.class.getSimpleName()));
-                    if (!hitUserBlacklist) {
+                    if (!hitUserBlacklist || !isInBlacklist) {
                         strategies.add(strategyMap.get(FlowPoolLastDayTopRecallStrategy.class.getSimpleName()));
                     }
                     strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));