丁云鹏 11 months ago
parent
commit
7f19e0d9f0

+ 5 - 3
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/remote/AIGCRemoteService.java

@@ -16,9 +16,7 @@ import org.apache.http.util.EntityUtils;
 import org.springframework.stereotype.Service;
 
 import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 
 /**
  * @author dyp
@@ -65,4 +63,8 @@ public class AIGCRemoteService {
         return result;
     }
 
+    public Set<String> historyTitle() {
+        return Collections.emptySet();
+    }
+
 }

+ 3 - 28
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/filter/FilterParam.java

@@ -1,41 +1,16 @@
 package com.tzld.longarticle.recommend.server.service.filter;
 
+import com.tzld.longarticle.recommend.server.model.Content;
 import lombok.Data;
 
 import java.util.List;
-import java.util.Map;
-import java.util.Set;
 
 /**
  * @author dyp
  */
 @Data
 public class FilterParam {
-    private List<Long> videoIds;
-    private Map<Long, String> flowPoolMap;
-    private int appType;
-    private String mid;
-    private String uid;
-
-    // 风险过滤
-    private Boolean riskFilterFlag;
-    private Map<Integer, List<String>> appRegionFiltered;
-    private List<Long> videosWithRisk;
-    private String regionCode;
-    private String cityCode;
-    private int forceTruncation;
-    private Set<String> abExpCodes;
-
-    public boolean concurrent; // hardcode 临时解决过滤慢的问题
-    public boolean notUsePreView;
-
-    // 层 - 实验
-    private Map<String, String> expIdMap;
-
-    private String abCode;
-
-    private Long hotSceneType;
-
-    private String clientIp;
+    private List<Content> contents;
+    private boolean flowPool;
 
 }

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

@@ -3,6 +3,8 @@ package com.tzld.longarticle.recommend.server.service.filter;
 import com.google.common.collect.Lists;
 import com.tzld.longarticle.recommend.server.common.ThreadPoolFactory;
 import com.tzld.longarticle.recommend.server.service.ServiceBeanFactory;
+import com.tzld.longarticle.recommend.server.service.filter.strategy.CategoryStrategy;
+import com.tzld.longarticle.recommend.server.service.filter.strategy.DuplicateStrategy;
 import com.tzld.longarticle.recommend.server.service.filter.strategy.SimilarityStrategy;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
@@ -22,12 +24,12 @@ public class FilterService {
     private final ExecutorService pool = ThreadPoolFactory.filterPool();
 
     public FilterResult filter(FilterParam param) {
-        List<Long> videoIds = viewFilter(param);
+        List<Long> videoIds = contentFilter(param);
 
         return new FilterResult(videoIds);
     }
 
-    protected List<Long> viewFilter(FilterParam param) {
+    private List<Long> contentFilter(FilterParam param) {
 
         List<FilterStrategy> strategies = getStrategies(param);
         CountDownLatch cdl = new CountDownLatch(strategies.size());
@@ -47,20 +49,20 @@ public class FilterService {
             return null;
         }
 
-        List<List<Long>> videoIds = new ArrayList<>();
+        List<List<Long>> contentIds = new ArrayList<>();
         for (Future<List<Long>> f : futures) {
             try {
-                videoIds.add(f.get());
+                contentIds.add(f.get());
             } catch (Exception e) {
                 log.error("future get error ", e);
             }
         }
-        if (CollectionUtils.isEmpty(videoIds)) {
+        if (CollectionUtils.isEmpty(contentIds)) {
             return Collections.emptyList();
         }
         List<Long> result = Lists.newArrayList(param.getVideoIds());
-        for (int i = 0; i < videoIds.size(); ++i) {
-            result.retainAll(videoIds.get(i));
+        for (int i = 0; i < contentIds.size(); ++i) {
+            result.retainAll(contentIds.get(i));
         }
         return result;
     }
@@ -68,6 +70,11 @@ public class FilterService {
     private List<FilterStrategy> getStrategies(FilterParam param) {
         List<FilterStrategy> strategies = new ArrayList<>();
         strategies.add(ServiceBeanFactory.getBean(SimilarityStrategy.class));
+        strategies.add(ServiceBeanFactory.getBean(DuplicateStrategy.class));
+
+        if (param.isFlowPool()) {
+            strategies.add(ServiceBeanFactory.getBean(CategoryStrategy.class));
+        }
 
         return strategies;
     }

+ 1 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/filter/strategy/SimilarityStrategy.java → long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/filter/strategy/CategoryStrategy.java

@@ -12,7 +12,7 @@ import java.util.List;
  */
 @Component
 @Slf4j
-public class SimilarityStrategy implements FilterStrategy {
+public class CategoryStrategy implements FilterStrategy {
 
     @Override
     public List<Long> filter(FilterParam param) {

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

@@ -0,0 +1,22 @@
+package com.tzld.longarticle.recommend.server.service.filter.strategy;
+
+import com.tzld.longarticle.recommend.server.service.filter.FilterParam;
+import com.tzld.longarticle.recommend.server.service.filter.FilterStrategy;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * @author dyp
+ */
+@Component
+@Slf4j
+public class DuplicateStrategy implements FilterStrategy {
+
+    @Override
+    public List<Long> filter(FilterParam param) {
+        return null;
+    }
+
+}

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

@@ -0,0 +1,30 @@
+package com.tzld.longarticle.recommend.server.service.filter.strategy;
+
+import com.tzld.longarticle.recommend.server.remote.AIGCRemoteService;
+import com.tzld.longarticle.recommend.server.service.filter.FilterParam;
+import com.tzld.longarticle.recommend.server.service.filter.FilterStrategy;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author dyp
+ */
+@Component
+@Slf4j
+public class HistoryTitleStrategy implements FilterStrategy {
+
+    @Autowired
+    private AIGCRemoteService aigcRemoteService;
+
+    @Override
+    public List<Long> filter(FilterParam param) {
+        Set<String> historyTitles = aigcRemoteService.historyTitle();
+
+        return null;
+    }
+
+}

+ 3 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/RankService.java

@@ -20,8 +20,11 @@ public class RankService {
     protected Map<String, String> bbb;
 
     public RankResult rank(RankParam param) {
+
+
         RankResult result = new RankResult();
 
+
         return result;
     }