supeng 3 weeks ago
parent
commit
5a525f4b87

+ 14 - 5
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/filter/strategy/RiskVideoStrategy.java

@@ -45,14 +45,23 @@ public class RiskVideoStrategy implements FilterStrategy {
             .build(new CacheLoader<String, Set<Long>>() {
                 @Override
                 public Set<Long> load(String key) {
-//                    List<WxVideoTagRel> rels = repository.findAllByTagIdIn(riskVideoTagIds);
-//                    return CommonCollectionUtils.toSet(rels, WxVideoTagRel::getVideoId);
+                    List<WxVideoTagRel> rels = repository.findAllByTagIdIn(riskVideoTagIds);
+//                    return CommonCollectionUtils.toSet(rels, WxVideoTagRel::getVideoId)
+                    //原标签内容保留 用于实时处理
+                    Set<Long> riskVideoIdSet = new HashSet<>();
+                    Set<Long> tagVideoIds = CommonCollectionUtils.toSet(rels, WxVideoTagRel::getVideoId);
+                    if (Objects.nonNull(tagVideoIds) && !tagVideoIds.isEmpty()) {
+                        riskVideoIdSet.addAll(tagVideoIds);
+                    }
                     //改为视频list 不超过10w条
                     Set<String> videoIdSet = redisTemplate.opsForSet().members(RedisKeyConstants.Recommend.WECHAT_RISK_VIDEO_CACHE_KEY);
-                    if (Objects.isNull(videoIdSet) || videoIdSet.isEmpty()) {
-                        return new HashSet<>();
+                    if (Objects.nonNull(videoIdSet) && !videoIdSet.isEmpty()) {
+                        Set<Long> riskVideoIds = videoIdSet.stream().map(Long::parseLong).collect(Collectors.toSet());
+                        if (!riskVideoIds.isEmpty()) {
+                            riskVideoIdSet.addAll(riskVideoIds);
+                        }
                     }
-                    return videoIdSet.stream().map(Long::parseLong).collect(Collectors.toSet());
+                    return riskVideoIdSet;
                 }
             });