|
@@ -33,6 +33,12 @@ public class RiskVideoStrategy implements FilterStrategy {
|
|
|
@ApolloJsonValue("${risk.video.tag:[]}")
|
|
@ApolloJsonValue("${risk.video.tag:[]}")
|
|
|
private List<Long> riskVideoTagIds;
|
|
private List<Long> riskVideoTagIds;
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 安全测试 风险标签
|
|
|
|
|
+ */
|
|
|
|
|
+ @ApolloJsonValue("${testing.risk.video.tag:[]}")
|
|
|
|
|
+ private List<Long> testingRiskVideoTagIds;
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private RedisTemplate<String, String> redisTemplate;
|
|
private RedisTemplate<String, String> redisTemplate;
|
|
|
|
|
|
|
@@ -69,6 +75,27 @@ public class RiskVideoStrategy implements FilterStrategy {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ private LoadingCache<String, Set<Long>> testingRiskVideoCache = CacheBuilder.newBuilder()
|
|
|
|
|
+ .maximumSize(10)
|
|
|
|
|
+ .refreshAfterWrite(600, TimeUnit.SECONDS)
|
|
|
|
|
+ .expireAfterWrite(600, TimeUnit.SECONDS)
|
|
|
|
|
+ .expireAfterAccess(600, TimeUnit.SECONDS)
|
|
|
|
|
+ .build(new CacheLoader<String, Set<Long>>() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Set<Long> load(String key) {
|
|
|
|
|
+ Set<Long> riskVideoIdSet = new HashSet<>();
|
|
|
|
|
+ if (Objects.nonNull(testingRiskVideoTagIds) && !testingRiskVideoTagIds.isEmpty()) {
|
|
|
|
|
+ //数量有限,一次查询,后续考虑优化
|
|
|
|
|
+ List<WxVideoTagRel> rels = repository.findAllByTagIdIn(testingRiskVideoTagIds);
|
|
|
|
|
+ Set<Long> tagVideoIds = CommonCollectionUtils.toSet(rels, WxVideoTagRel::getVideoId);
|
|
|
|
|
+ if (Objects.nonNull(tagVideoIds) && !tagVideoIds.isEmpty()) {
|
|
|
|
|
+ riskVideoIdSet = tagVideoIds;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return riskVideoIdSet;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public List<Long> filter(FilterParam param) {
|
|
public List<Long> filter(FilterParam param) {
|
|
|
if (param == null) {
|
|
if (param == null) {
|
|
@@ -78,14 +105,24 @@ public class RiskVideoStrategy implements FilterStrategy {
|
|
|
return param.getVideoIds();
|
|
return param.getVideoIds();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (!param.isRiskUser()) {
|
|
|
|
|
|
|
+ if (!param.isRiskUser() && !param.isTestingRiskRegion()) {
|
|
|
return param.getVideoIds();
|
|
return param.getVideoIds();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- Set<Long> riskVids = riskVideoCache.getUnchecked("");
|
|
|
|
|
- List<Long> videoIds = param.getVideoIds().stream()
|
|
|
|
|
- .filter(l -> !riskVids.contains(l))
|
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
|
|
|
+ List<Long> videoIds = param.getVideoIds();
|
|
|
|
|
+ if (param.isRiskUser()) {
|
|
|
|
|
+ Set<Long> riskVids = riskVideoCache.getUnchecked("");
|
|
|
|
|
+ videoIds = videoIds.stream()
|
|
|
|
|
+ .filter(l -> !riskVids.contains(l))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (param.isTestingRiskRegion()) {
|
|
|
|
|
+ Set<Long> riskVids = testingRiskVideoCache.getUnchecked("");
|
|
|
|
|
+ videoIds = videoIds.stream()
|
|
|
|
|
+ .filter(l -> !riskVids.contains(l))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
log.info("RiskVideoStrategy \t param={} \t before={} \t after={}",
|
|
log.info("RiskVideoStrategy \t param={} \t before={} \t after={}",
|
|
|
JSONUtils.toJson(param),
|
|
JSONUtils.toJson(param),
|