|
@@ -7,49 +7,39 @@ import com.tzld.piaoquan.recommend.server.framework.recaller.AbstractFilter;
|
|
|
import com.tzld.piaoquan.recommend.server.framework.recaller.FilterConfigInfo;
|
|
|
import com.tzld.piaoquan.recommend.server.gen.recommend.RecommendRequest;
|
|
|
import com.tzld.piaoquan.recommend.server.model.Video;
|
|
|
-import com.tzld.piaoquan.recommend.server.repository.WxVideoStatusRepository;
|
|
|
-import com.tzld.piaoquan.recommend.server.service.PreViewedService;
|
|
|
+import com.tzld.piaoquan.recommend.server.service.SpringContextHolder;
|
|
|
+import com.tzld.piaoquan.recommend.server.service.filter.FilterParam;
|
|
|
+import com.tzld.piaoquan.recommend.server.service.filter.strategy.RecommendStatusStrategy;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
-import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
public class RecommendStatusFilter extends AbstractFilter<Video> {
|
|
|
|
|
|
- @Autowired
|
|
|
- @Qualifier("redisTemplate")
|
|
|
- private RedisTemplate<String, String> redisTemplate;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private WxVideoStatusRepository wxVideoStatusRepository;
|
|
|
-
|
|
|
- private String keyFormat = "video:recommend:status:%s";
|
|
|
-
|
|
|
- private static final int RECOMMEND_STATUS = -6;
|
|
|
-
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private PreViewedService preViewedService;
|
|
|
+ private final RecommendStatusStrategy recommendStatusStrategy;
|
|
|
|
|
|
public RecommendStatusFilter(FilterConfigInfo filterConfigInfo,
|
|
|
RecommendRequest recommendRequest,
|
|
|
User user) {
|
|
|
super(filterConfigInfo, recommendRequest, user);
|
|
|
-
|
|
|
+ recommendStatusStrategy = SpringContextHolder.getBean(RecommendStatusStrategy.class);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void doFilter(Candidate candidate, List<Video> t) {
|
|
|
- if (CollectionUtils.isEmpty(t)) {
|
|
|
+ public void doFilter(Candidate candidate, List<Video> videos) {
|
|
|
+ if (CollectionUtils.isEmpty(videos)) {
|
|
|
return;
|
|
|
}
|
|
|
+ FilterParam filterParam = new FilterParam();
|
|
|
+ filterParam.setVideoIds(videos.stream().map(Video::getVideoId).collect(Collectors.toList()));
|
|
|
+ List<Long> videoIdList = recommendStatusStrategy.filter(filterParam);
|
|
|
+ Set<Long> videoIdSet = new HashSet<>(videoIdList);
|
|
|
+ videos.removeIf(video -> !videoIdSet.contains(video.getVideoId()));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|