|
@@ -175,6 +175,31 @@ public class FoodRecommendService {
|
|
|
return result;
|
|
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) {
|
|
public List<FoodRecommendIdxLog> getIndexHistory(Long userId, Long foodId) {
|
|
|
return foodRecommendIdxLogMapper.selectList(
|
|
return foodRecommendIdxLogMapper.selectList(
|
|
|
new LambdaQueryWrapper<FoodRecommendIdxLog>()
|
|
new LambdaQueryWrapper<FoodRecommendIdxLog>()
|