|
@@ -1,10 +1,9 @@
|
|
|
package com.tzld.longarticle.recommend.server.service.filter.strategy;
|
|
|
|
|
|
-import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
|
|
|
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.AccountContentPoolConfig;
|
|
|
+import com.tzld.longarticle.recommend.server.service.AccountContentPoolConfigService;
|
|
|
import com.tzld.longarticle.recommend.server.service.filter.FilterParam;
|
|
|
import com.tzld.longarticle.recommend.server.service.filter.FilterResult;
|
|
|
import com.tzld.longarticle.recommend.server.service.filter.FilterStrategy;
|
|
@@ -29,26 +28,28 @@ public class HistoryTitleStrategy implements FilterStrategy {
|
|
|
|
|
|
@Autowired
|
|
|
private ArticleListRemoteService articleListRemoteService;
|
|
|
+ @Autowired
|
|
|
+ private AccountContentPoolConfigService accountContentPoolConfigService;
|
|
|
|
|
|
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);
|
|
|
|
|
|
- @ApolloJsonValue("${accountContentPoolConfig:[]}")
|
|
|
- private List<AccountContentPoolConfig> accountContentPoolConfigList;
|
|
|
|
|
|
@Override
|
|
|
public FilterResult filter(FilterParam param) {
|
|
|
FilterResult filterResult = new FilterResult();
|
|
|
List<String> result = new ArrayList<>();
|
|
|
- List<Content> filterContents = new ArrayList<>();
|
|
|
+ List<Content> filterContents = 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());
|
|
|
- AccountContentPoolConfig contentPoolConfig = getContentPoolConfig(param.getAccountName());
|
|
|
+
|
|
|
+
|
|
|
List<String> firstSecondContentPool = new ArrayList<>();
|
|
|
+ String[] contentPoolConfig = accountContentPoolConfigService.getContentPools(param.getAccountName());
|
|
|
if (Objects.nonNull(contentPoolConfig)) {
|
|
|
- firstSecondContentPool = Arrays.asList(contentPoolConfig.getContentPools()[0], contentPoolConfig.getContentPools()[1]);
|
|
|
+ firstSecondContentPool = Arrays.asList(contentPoolConfig[0], contentPoolConfig[1]);
|
|
|
}
|
|
|
for (Content content : param.getContents()) {
|
|
|
boolean isDuplicate;
|
|
@@ -70,13 +71,4 @@ public class HistoryTitleStrategy implements FilterStrategy {
|
|
|
return filterResult;
|
|
|
}
|
|
|
|
|
|
- private AccountContentPoolConfig getContentPoolConfig(String accountName) {
|
|
|
- for (AccountContentPoolConfig contentPoolConfig : accountContentPoolConfigList) {
|
|
|
- if (accountName.equals(contentPoolConfig.getAccount())) {
|
|
|
- return contentPoolConfig;
|
|
|
- }
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
}
|