|
@@ -81,27 +81,59 @@ public class RankV3Strategy implements RankStrategy {
|
|
|
// 4 选文章
|
|
|
List<Content> result = new ArrayList<>();
|
|
|
String[] contentPools = accountContentPoolConfigService.getContentPools(param.getAccountName());
|
|
|
- // 头
|
|
|
- List<Content> pool = contentMap.get(contentPools[0]);
|
|
|
- if (CollectionUtils.isNotEmpty(pool)) {
|
|
|
- result.add(pool.get(0));
|
|
|
- }
|
|
|
- // 次
|
|
|
- pool = contentMap.get(contentPools[1]);
|
|
|
- if (CollectionUtils.isNotEmpty(pool)) {
|
|
|
- if (StringUtils.equals(contentPools[0], contentPools[1])) {
|
|
|
- if (pool.size() > 2) {
|
|
|
- result.add(pool.get(2));
|
|
|
+
|
|
|
+
|
|
|
+ // 头、次
|
|
|
+ if (StringUtils.equals(contentPools[0], contentPools[1])) {
|
|
|
+ List<Content> pool = contentMap.get(contentPools[0]);
|
|
|
+ Integer level = accountContentPoolConfigService.getLevelByContentPool(contentPools[0]);
|
|
|
+ if (level == 1) {
|
|
|
+ if (CollectionUtils.isNotEmpty(pool)) {
|
|
|
+ result.add(pool.get(0));
|
|
|
+ if (pool.size() > 2) {
|
|
|
+ result.add(pool.get(2));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // level2 兜底
|
|
|
+ pool = contentMap.get(accountContentPoolConfigService.getContentPoolByLevel(2));
|
|
|
+ if (CollectionUtils.isNotEmpty(pool)) {
|
|
|
+ result.add(pool.get(0));
|
|
|
+ if (pool.size() > 1) {
|
|
|
+ result.add(pool.get(1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (level == 2) {
|
|
|
+ if (CollectionUtils.isNotEmpty(pool)) {
|
|
|
+ pool = pool.subList(0, Math.max(10, pool.size()));
|
|
|
+ Collections.shuffle(pool);
|
|
|
+ result.add(pool.get(0));
|
|
|
+ if (pool.size() > 1) {
|
|
|
+ result.add(pool.get(1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 配置错误 兜底
|
|
|
+ List<Content> pool1 = contentMap.get(contentPools[0]);
|
|
|
+ List<Content> pool2 = contentMap.get(contentPools[1]);
|
|
|
+ if (CollectionUtils.isNotEmpty(pool1)) {
|
|
|
+ result.add(pool1.get(0));
|
|
|
+ if (CollectionUtils.isNotEmpty(pool2)) {
|
|
|
+ result.add(pool2.get(0));
|
|
|
+ }
|
|
|
+ } else if (CollectionUtils.isNotEmpty(pool2)) {
|
|
|
+ result.add(pool2.get(0));
|
|
|
+ if (pool2.size() > 1) {
|
|
|
+ result.add(pool2.get(1));
|
|
|
}
|
|
|
- } else {
|
|
|
- result.add(pool.get(0));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// 3-8
|
|
|
- pool = contentMap.get(contentPools[2]);
|
|
|
+ List<Content> pool = contentMap.get(contentPools[2]);
|
|
|
if (CollectionUtils.isNotEmpty(pool)) {
|
|
|
+ Collections.shuffle(pool);
|
|
|
result.addAll(pool.subList(0, Math.min(pool.size(), param.getSize() - result.size())));
|
|
|
}
|
|
|
|