zhaohaipeng пре 1 година
родитељ
комит
c2f0a4f324

+ 24 - 23
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/filter/strategy/SecurityStrategy.java

@@ -20,6 +20,7 @@ import javax.annotation.PostConstruct;
 import javax.annotation.Resource;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
 
 /**
  * @author dyp
@@ -89,29 +90,29 @@ public class SecurityStrategy implements FilterStrategy {
             return param.getVideoIds();
         }
 
-        // if (CollectionUtils.isEmpty(excludeScenes)
-        //         || !CommonCollectionUtils.contains(excludeScenes, param.getHotSceneType())) {
-        //
-        //     if (MapUtils.isEmpty(videoFilterCityTagIdMap)
-        //             || !videoFilterCityTagIdMap.containsKey(param.getCityCode())) {
-        //         return param.getVideoIds();
-        //     }
-        //
-        //     Set<Long> filterVideos = videoCache.getUnchecked(param.getCityCode());
-        //     if (CollectionUtils.isEmpty(filterVideos)) {
-        //         return param.getVideoIds();
-        //     }
-        //
-        //     List<Long> result = param.getVideoIds().stream()
-        //             .filter(l -> !filterVideos.contains(l))
-        //             .collect(Collectors.toList());
-        //
-        //     return result;
-        // }
-        // return param.getVideoIds();
-
-        return blacklistContainer.filterUnsafeVideoByUser(param.getVideoIds(), param.getUid(),
-                param.getHotSceneType(), param.getCityCode(), param.getClientIp());
+        if (CollectionUtils.isEmpty(excludeScenes)
+                || !CommonCollectionUtils.contains(excludeScenes, param.getHotSceneType())) {
+
+            if (MapUtils.isEmpty(videoFilterCityTagIdMap)
+                    || !videoFilterCityTagIdMap.containsKey(param.getCityCode())) {
+                return param.getVideoIds();
+            }
+
+            Set<Long> filterVideos = videoCache.getUnchecked(param.getCityCode());
+            if (CollectionUtils.isEmpty(filterVideos)) {
+                return param.getVideoIds();
+            }
+
+            List<Long> result = param.getVideoIds().stream()
+                    .filter(l -> !filterVideos.contains(l))
+                    .collect(Collectors.toList());
+
+            return result;
+        }
+        return param.getVideoIds();
+
+        // return blacklistContainer.filterUnsafeVideoByUser(param.getVideoIds(), param.getUid(),
+        //         param.getHotSceneType(), param.getCityCode(), param.getClientIp());
 
     }
 }