|
@@ -0,0 +1,61 @@
|
|
|
+package com.tzld.longarticle.recommend.server.service.recommend.filter.strategy;
|
|
|
+
|
|
|
+import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
|
|
|
+import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishPlanInputSourceTypesEnum;
|
|
|
+import com.tzld.longarticle.recommend.server.common.enums.longArticle.ArticleVideoAuditStatusEnum;
|
|
|
+import com.tzld.longarticle.recommend.server.model.dto.Content;
|
|
|
+import com.tzld.longarticle.recommend.server.model.entity.longArticle.LongArticleTitleAudit;
|
|
|
+import com.tzld.longarticle.recommend.server.repository.longArticle.LongArticleTitleAuditRepository;
|
|
|
+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 java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Component
|
|
|
+@Slf4j
|
|
|
+public class VideoAuditStrategy implements FilterStrategy {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ LongArticleTitleAuditRepository titleAuditRepository;
|
|
|
+
|
|
|
+ @ApolloJsonValue("${whiteAccountList:[]}")
|
|
|
+ private List<String> whiteAccountList;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保留视频内容池和视频审核通过的内容
|
|
|
+ * 不对其他内容做废弃操作
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public FilterResult filter(FilterParam param) {
|
|
|
+ FilterResult filterResult = new FilterResult();
|
|
|
+ List<String> result = new ArrayList<>(param.getContents().size());
|
|
|
+ // 仅白名单账号执行下方过滤,其他账号直接返回
|
|
|
+ if (!whiteAccountList.contains(param.getAccountName())) {
|
|
|
+ filterResult.setContentIds(param.getContents().stream().map(Content::getId).collect(Collectors.toList()));
|
|
|
+ return filterResult;
|
|
|
+ }
|
|
|
+ List<String> sourceIds = param.getContents().stream().map(Content::getSourceId).collect(Collectors.toList());
|
|
|
+ List<LongArticleTitleAudit> titleAuditList = titleAuditRepository.getByContentIdIn(sourceIds);
|
|
|
+ Map<String, Integer> titleAuditMap = titleAuditList.stream()
|
|
|
+ .collect(Collectors.toMap(LongArticleTitleAudit::getContentId, LongArticleTitleAudit::getStatus));
|
|
|
+ for (Content content : param.getContents()) {
|
|
|
+ // 视频内容池 或 视频审核通过
|
|
|
+ if (Objects.equals(content.getSourceType(), PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal())
|
|
|
+ || (Objects.nonNull(titleAuditMap.get(content.getSourceId()))
|
|
|
+ && titleAuditMap.get(content.getSourceId()) == ArticleVideoAuditStatusEnum.PASS.getCode())) {
|
|
|
+ result.add(content.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ filterResult.setContentIds(result);
|
|
|
+ return filterResult;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|