|
@@ -1,14 +1,19 @@
|
|
|
package com.tzld.longarticle.recommend.server.service.filter.strategy;
|
|
|
|
|
|
-import com.tzld.longarticle.recommend.server.remote.AIGCRemoteService;
|
|
|
+import com.tzld.longarticle.recommend.server.model.Content;
|
|
|
+import com.tzld.longarticle.recommend.server.model.remote.Article;
|
|
|
+import com.tzld.longarticle.recommend.server.remote.ArticleListRemoteService;
|
|
|
import com.tzld.longarticle.recommend.server.service.filter.FilterParam;
|
|
|
import com.tzld.longarticle.recommend.server.service.filter.FilterStrategy;
|
|
|
+import com.tzld.longarticle.recommend.server.util.TitleSimilarCheckUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
-import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author dyp
|
|
@@ -18,13 +23,31 @@ import java.util.Set;
|
|
|
public class HistoryTitleStrategy implements FilterStrategy {
|
|
|
|
|
|
@Autowired
|
|
|
- private AIGCRemoteService aigcRemoteService;
|
|
|
+ private ArticleListRemoteService articleListRemoteService;
|
|
|
+
|
|
|
+ private static final List<Integer> firstSecondIndex = Arrays.asList(1, 2);
|
|
|
+ private static final List<Integer> allIndex = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8);
|
|
|
|
|
|
@Override
|
|
|
public List<String> filter(FilterParam param) {
|
|
|
- Set<String> historyTitles = aigcRemoteService.historyTitle();
|
|
|
-
|
|
|
- return null;
|
|
|
+ List<String> result = new ArrayList<>();
|
|
|
+ List<Article> firstSecondArticleList = articleListRemoteService.articleList(param.getAccountName(), firstSecondIndex);
|
|
|
+ List<String> firstSecondTitleList = firstSecondArticleList.stream().map(Article::getTitle).collect(Collectors.toList());
|
|
|
+ List<Article> allArticleList = articleListRemoteService.articleList(param.getAccountName(), allIndex);
|
|
|
+ List<String> allTitleList = allArticleList.stream().map(Article::getTitle).collect(Collectors.toList());
|
|
|
+ for (Content content : param.getContents()) {
|
|
|
+ boolean isDuplicate;
|
|
|
+ if (content.getProducePlanName().contains("【1】")
|
|
|
+ || content.getProducePlanName().contains("【2】")) {
|
|
|
+ isDuplicate = TitleSimilarCheckUtil.isDuplicateContent(content.getTitle(), firstSecondTitleList);
|
|
|
+ } else {
|
|
|
+ isDuplicate = TitleSimilarCheckUtil.isDuplicateContent(content.getTitle(), allTitleList);
|
|
|
+ }
|
|
|
+ if (!isDuplicate) {
|
|
|
+ result.add(content.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
}
|