|
@@ -59,17 +59,21 @@ public class RankService {
|
|
|
if (i == 1) {
|
|
|
// 播放量排序
|
|
|
List<RankItem> data = itemMap.get(contentPools[i]);
|
|
|
- Collections.sort(data, (o1, o2) -> -Double.compare(
|
|
|
- o1.getScore(ViewCountStrategy.class.getSimpleName()),
|
|
|
- o2.getScore(ViewCountStrategy.class.getSimpleName())));
|
|
|
- sortedItems.addAll(data);
|
|
|
+ if (CollectionUtils.isNotEmpty(data)) {
|
|
|
+ Collections.sort(data, (o1, o2) -> -Double.compare(
|
|
|
+ o1.getScore(ViewCountStrategy.class.getSimpleName()),
|
|
|
+ o2.getScore(ViewCountStrategy.class.getSimpleName())));
|
|
|
+ sortedItems.addAll(data);
|
|
|
+ }
|
|
|
} else {
|
|
|
// 相似排序
|
|
|
List<RankItem> data = itemMap.get(contentPools[i]);
|
|
|
- Collections.sort(data, (o1, o2) -> -Double.compare(
|
|
|
- o1.getScore(SimilarityStrategy.class.getSimpleName()),
|
|
|
- o2.getScore(SimilarityStrategy.class.getSimpleName())));
|
|
|
- sortedItems.addAll(data);
|
|
|
+ if (CollectionUtils.isNotEmpty(data)) {
|
|
|
+ Collections.sort(data, (o1, o2) -> -Double.compare(
|
|
|
+ o1.getScore(SimilarityStrategy.class.getSimpleName()),
|
|
|
+ o2.getScore(SimilarityStrategy.class.getSimpleName())));
|
|
|
+ sortedItems.addAll(data);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
List<Content> contents = CommonCollectionUtils.toList(sortedItems, RankItem::getContent);
|