Kaynağa Gözat

内容已晋级过滤

wangyunpeng 8 ay önce
ebeveyn
işleme
48b37c5d98

+ 2 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/longArticle/ArticlePoolPromotionSourceRepository.java

@@ -11,5 +11,7 @@ public interface ArticlePoolPromotionSourceRepository extends JpaRepository<Arti
 
     List<ArticlePoolPromotionSource> getByChannelContentId(String channelContentId);
 
+    List<ArticlePoolPromotionSource> getByChannelContentIdInAndStatusAndDeleted(List<String> channelContentIds, Integer status, Integer deleted);
+
     List<ArticlePoolPromotionSource> getByStatus(Integer status);
 }

+ 1 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/filter/FilterService.java

@@ -93,6 +93,7 @@ public class FilterService {
         strategies.add(ServiceBeanFactory.getBean(SensitiveStrategy.class));
         strategies.add(ServiceBeanFactory.getBean(DeDuplicationStrategy.class));
         strategies.add(ServiceBeanFactory.getBean(KeywordStrategy.class));
+        strategies.add(ServiceBeanFactory.getBean(ContentPoolStrategy.class));
         if (param.getScene().equals(FWH_COLD_START)) {
             strategies.add(ServiceBeanFactory.getBean(HistoryTitleForFwhColdStartStrategy.class));
         } else {

+ 52 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/filter/strategy/ContentPoolStrategy.java

@@ -0,0 +1,52 @@
+package com.tzld.longarticle.recommend.server.service.recommend.filter.strategy;
+
+import com.tzld.longarticle.recommend.server.model.dto.Content;
+import com.tzld.longarticle.recommend.server.model.entity.longArticle.ArticlePoolPromotionSource;
+import com.tzld.longarticle.recommend.server.repository.longArticle.ArticlePoolPromotionSourceRepository;
+import com.tzld.longarticle.recommend.server.service.recommend.filter.FilterParam;
+import com.tzld.longarticle.recommend.server.service.recommend.filter.FilterResult;
+import com.tzld.longarticle.recommend.server.service.recommend.filter.FilterStrategy;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Component
+@Slf4j
+public class ContentPoolStrategy implements FilterStrategy {
+
+    @Autowired
+    ArticlePoolPromotionSourceRepository repository;
+
+    @Override
+    public FilterResult filter(FilterParam param) {
+        FilterResult filterResult = new FilterResult();
+        List<String> result = new ArrayList<>();
+        List<Content> contents = param.getContents();
+        List<Content> filterContents = new ArrayList<>();
+        List<String> channelContentIds = contents.stream().map(Content::getCrawlerChannelContentId).collect(Collectors.toList());
+        List<ArticlePoolPromotionSource> promotionSourceList = repository.getByChannelContentIdInAndStatusAndDeleted(channelContentIds, 1, 0);
+        Map<String, ArticlePoolPromotionSource> promotionSourceMap = promotionSourceList.stream().collect(Collectors.toMap(ArticlePoolPromotionSource::getChannelContentId, a -> a));
+        for (Content content : contents) {
+            if (promotionSourceMap.containsKey(content.getCrawlerChannelContentId())) {
+                ArticlePoolPromotionSource promotionSource = promotionSourceMap.get(content.getCrawlerChannelContentId());
+                if (promotionSource.getLevel().equals(content.getContentPoolType())) {
+                    content.setFilterReason("内容已晋级过滤");
+                    filterContents.add(content);
+                }
+            }
+            if (!StringUtils.hasText(content.getFilterReason())) {
+                result.add(content.getId());
+            }
+        }
+        filterResult.setContentIds(result);
+        filterResult.setFilterContent(filterContents);
+        return filterResult;
+    }
+
+}