Browse Source

fix: ContentRecommendService NPE when type is null

switch(type) throws NullPointerException when request type is missing. Added null guard before switch.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Xiaogang Liao 1 month ago
parent
commit
ad28e68b90

+ 3 - 1
cfc-backend/src/main/java/com/etotem/cfc/service/ContentRecommendService.java

@@ -68,7 +68,9 @@ public class ContentRecommendService {
 
         List<RecommendItemVO> items;
 
-        switch (type) {
+        if (type == null) {
+            items = new ArrayList<>();
+        } else switch (type) {
             case "article":
                 items = recommendArticles(dimensionCode, userId, familyId, childId, excludeIds);
                 break;