فهرست منبع

chore: auto bump version and changelog [skip ci]

iwt 2 هفته پیش
والد
کامیت
f382501474
2فایلهای تغییر یافته به همراه26 افزوده شده و 1 حذف شده
  1. 25 0
      cfc-backend/src/main/java/com/etotem/cfc/service/FoodRecommendService.java
  2. 1 1
      cfc-web/.last_build_commit

+ 25 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/FoodRecommendService.java

@@ -175,6 +175,31 @@ public class FoodRecommendService {
         return result;
     }
 
+    /** 将当前食材数据转换为 Food 实体列表,供 /api/health/foods 无 reportId 时使用 */
+    public List<Food> getCurrentFoodsAsFoodList(Long userId) {
+        List<Map<String, Object>> current = getCurrentFoods(userId);
+        List<Food> result = new ArrayList<>();
+        for (Map<String, Object> m : current) {
+            Food food = new Food();
+            food.setName((String) m.get("name"));
+            food.setCategory((String) m.get("category"));
+            Integer score = (Integer) m.get("score");
+            if (score != null) food.setScore(score);
+            BigDecimal protein = (BigDecimal) m.get("protein");
+            if (protein != null) food.setProtein(protein);
+            BigDecimal fat = (BigDecimal) m.get("fat");
+            if (fat != null) food.setFat(fat);
+            BigDecimal carbs = (BigDecimal) m.get("carbs");
+            if (carbs != null) food.setCarbs(carbs);
+            BigDecimal fiber = (BigDecimal) m.get("fiber");
+            if (fiber != null) food.setFiber(fiber);
+            BigDecimal energyKj = (BigDecimal) m.get("energyKj");
+            if (energyKj != null) food.setEnergyKj(energyKj);
+            result.add(food);
+        }
+        return result;
+    }
+
     public List<FoodRecommendIdxLog> getIndexHistory(Long userId, Long foodId) {
         return foodRecommendIdxLogMapper.selectList(
                 new LambdaQueryWrapper<FoodRecommendIdxLog>()

+ 1 - 1
cfc-web/.last_build_commit

@@ -1 +1 @@
-c4edf81675e65bd1ce6f35895d6d57f36849ef87
+77af25cd183284f1e7d2efebc1150d3fd65a02cb