Explorar el Código

头条内容不足返回空

wangyunpeng hace 7 meses
padre
commit
ff62dd6909

+ 2 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/DefaultRankStrategy.java

@@ -104,6 +104,8 @@ public class DefaultRankStrategy implements RankStrategy {
         List<Content> pool = contentMap.get(contentPools[0]);
         if (CollectionUtils.isNotEmpty(pool)) {
             result.add(pool.get(RandomUtils.nextInt(0, Math.min(pool.size(), 5))));
+        } else {
+            return new RankResult(result);
         }
 
         // 次

+ 1 - 9
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV10Strategy.java

@@ -92,15 +92,7 @@ public class RankV10Strategy implements RankStrategy {
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
-            // 替补
-            AccountIndexReplacePoolConfig replacePoolConfig = indexReplacePoolConfigMap.get(1);
-            if (Objects.nonNull(replacePoolConfig)) {
-                List<Content> pool1Replace = contentMap.get(replacePoolConfig.getContentPool());
-                if (CollectionUtils.isNotEmpty(pool1Replace)) {
-                    publishPool[0] = replacePoolConfig.getContentPool();
-                    result.add(pool1Replace.get(0));
-                }
-            }
+            return new RankResult(result);
         }
         // 次
         List<Content> pool2 = contentMap.get(contentPools[1]);

+ 4 - 18
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV4Strategy.java

@@ -98,14 +98,7 @@ public class RankV4Strategy implements RankStrategy {
                         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));
-                        }
-                    }
+                    return new RankResult(result);
                 }
             } else if (level == 2) {
                 if (CollectionUtils.isNotEmpty(pool)) {
@@ -114,10 +107,7 @@ public class RankV4Strategy implements RankStrategy {
                         result.add(pool.get(1));
                     }
                 } else {
-                    pool = contentMap.get(ContentPoolEnum.autoArticlePoolLevel1.getContentPool());
-                    if (CollectionUtils.isNotEmpty(pool)) {
-                        result.add(pool.get(0));
-                    }
+                    return new RankResult(result);
                 }
             }
         } else {
@@ -129,12 +119,8 @@ public class RankV4Strategy implements RankStrategy {
                 if (CollectionUtils.isNotEmpty(pool2)) {
                     result.add(pool2.get(0));
                 }
-            } else if (CollectionUtils.isNotEmpty(pool2)) {
-                result.add(pool2.get(0));
-                publishPool[0] = contentPools[1];
-                if (pool2.size() > 1) {
-                    result.add(pool2.get(1));
-                }
+            } else {
+                return new RankResult(result);
             }
         }
 

+ 1 - 9
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV5Strategy.java

@@ -91,15 +91,7 @@ public class RankV5Strategy implements RankStrategy {
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
-            // 替补
-            AccountIndexReplacePoolConfig replacePoolConfig = indexReplacePoolConfigMap.get(1);
-            if (Objects.nonNull(replacePoolConfig)) {
-                List<Content> pool1Replace = contentMap.get(replacePoolConfig.getContentPool());
-                if (CollectionUtils.isNotEmpty(pool1Replace)) {
-                    publishPool[0] = replacePoolConfig.getContentPool();
-                    result.add(pool1Replace.get(0));
-                }
-            }
+            return new RankResult(result);
         }
         // 次
         List<Content> pool2 = contentMap.get(contentPools[1]);

+ 1 - 9
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV7Strategy.java

@@ -92,15 +92,7 @@ public class RankV7Strategy implements RankStrategy {
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
-            // 替补
-            AccountIndexReplacePoolConfig replacePoolConfig = indexReplacePoolConfigMap.get(1);
-            if (Objects.nonNull(replacePoolConfig)) {
-                List<Content> pool1Replace = contentMap.get(replacePoolConfig.getContentPool());
-                if (CollectionUtils.isNotEmpty(pool1Replace)) {
-                    publishPool[0] = replacePoolConfig.getContentPool();
-                    result.add(pool1Replace.get(0));
-                }
-            }
+            return new RankResult(result);
         }
         // 次
         List<Content> pool2 = contentMap.get(contentPools[1]);

+ 1 - 9
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV8Strategy.java

@@ -95,15 +95,7 @@ public class RankV8Strategy implements RankStrategy {
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
-            // 替补
-            AccountIndexReplacePoolConfig replacePoolConfig = indexReplacePoolConfigMap.get(1);
-            if (Objects.nonNull(replacePoolConfig)) {
-                List<Content> pool1Replace = contentMap.get(replacePoolConfig.getContentPool());
-                if (CollectionUtils.isNotEmpty(pool1Replace)) {
-                    publishPool[0] = replacePoolConfig.getContentPool();
-                    result.add(pool1Replace.get(0));
-                }
-            }
+            return new RankResult(result);
         }
         // 次
         List<Content> pool2 = contentMap.get(contentPools[1]);

+ 1 - 9
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV9Strategy.java

@@ -92,15 +92,7 @@ public class RankV9Strategy implements RankStrategy {
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
-            // 替补
-            AccountIndexReplacePoolConfig replacePoolConfig = indexReplacePoolConfigMap.get(1);
-            if (Objects.nonNull(replacePoolConfig)) {
-                List<Content> pool1Replace = contentMap.get(replacePoolConfig.getContentPool());
-                if (CollectionUtils.isNotEmpty(pool1Replace)) {
-                    publishPool[0] = replacePoolConfig.getContentPool();
-                    result.add(pool1Replace.get(0));
-                }
-            }
+            return new RankResult(result);
         }
         // 次
         List<Content> pool2 = contentMap.get(contentPools[1]);