Explorar o código

feat(diet): 健康报告食材推荐接口支持 memberId 查询孩子视角

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

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
E2E Test Bot hai 1 mes
pai
achega
975276da83

+ 4 - 2
cfc-backend/src/main/java/com/etotem/cfc/controller/HealthReportController.java

@@ -1463,8 +1463,10 @@ public class HealthReportController {
             // 指定报告:返回该报告的食材推荐
             foods = foodService.listByReportId(reportId);
         } else {
-            // 未指定报告:返回维护的"当前食材"推荐(food_recommend_idx,有新报告时 upsert 更新)
-            Long uid = userId != null ? userId : -1L;
+            // 未指定报告:优先用 memberId(孩子视角),其次 JWT userId(家长视角)
+            // food_recommend_idx 以 subjectId 维度写入,家长 JWT userId 查不到孩子的推荐
+            Long memberId = params != null ? ParamUtils.getLong(params.get("memberId")) : null;
+            Long uid = memberId != null ? memberId : (userId != null ? userId : -1L);
             foods = foodRecommendService.getCurrentFoodsAsFoodList(uid);
         }
         return Result.success(foods);