Procházet zdrojové kódy

chore: auto bump version and changelog [skip ci]

iwt před 2 týdny
rodič
revize
a9defdbd0b

+ 14 - 11
cfc-backend/src/main/java/com/etotem/cfc/service/FoodRecommendService.java

@@ -36,6 +36,9 @@ public class FoodRecommendService {
     @Resource
     private HealthReportService healthReportService;
 
+    @Resource
+    private FoodService foodService;
+
     @Transactional
     public void recalculateForUser(Long userId) {
         HealthReport report = healthReportService.getLatestReport(userId);
@@ -46,15 +49,13 @@ public class FoodRecommendService {
             return;
         }
 
-        List<ReportFoodSuitability> suitList = reportFoodSuitabilityMapper.selectList(
-                new LambdaQueryWrapper<ReportFoodSuitability>()
-                        .eq(ReportFoodSuitability::getReportId, report.getId())
-        );
+        // 从 foods 表读取最新报告关联的食材推荐(正常确认流程写入 foods 表)
+        List<Food> reportFoods = foodService.listByReportId(report.getId());
 
-        if (suitList.isEmpty()) {
+        if (reportFoods.isEmpty()) {
             foodRecommendIndexMapper.delete(new LambdaQueryWrapper<FoodRecommendIndex>()
                     .eq(FoodRecommendIndex::getUserId, userId));
-            log.info("报告{}无食材适宜度数据,已清除用户{}的推荐指数", report.getId(), userId);
+            log.info("报告{}无食材推荐数据,已清除用户{}的推荐指数", report.getId(), userId);
             return;
         }
 
@@ -69,15 +70,17 @@ public class FoodRecommendService {
         Date now = new Date();
         Long reportId = report.getId();
 
-        for (ReportFoodSuitability suit : suitList) {
-            Long foodId = suit.getFoodId();
-            Integer newIndex = suit.getScore();
+        for (Food food : reportFoods) {
+            Long foodId = food.getId();
+            Integer newIndex = food.getScore();
+            String foodName = food.getName();
             FoodRecommendIndex existing = existingMap.get(foodId);
 
             if (existing != null) {
                 if (!Objects.equals(existing.getIndexScore(), newIndex)) {
                     Integer oldIndex = existing.getIndexScore();
                     existing.setIndexScore(newIndex);
+                    existing.setFoodName(foodName);
                     existing.setHealthReportId(reportId);
                     existing.setCalculatedAt(now);
                     foodRecommendIndexMapper.updateById(existing);
@@ -85,7 +88,7 @@ public class FoodRecommendService {
                     FoodRecommendIdxLog logEntry = new FoodRecommendIdxLog();
                     logEntry.setUserId(userId);
                     logEntry.setFoodId(foodId);
-                    logEntry.setFoodName(suit.getFoodName());
+                    logEntry.setFoodName(foodName);
                     logEntry.setPreviousIndex(oldIndex);
                     logEntry.setNewIndex(newIndex);
                     logEntry.setHealthReportId(reportId);
@@ -99,7 +102,7 @@ public class FoodRecommendService {
                 FoodRecommendIndex index = new FoodRecommendIndex();
                 index.setUserId(userId);
                 index.setFoodId(foodId);
-                index.setFoodName(suit.getFoodName());
+                index.setFoodName(foodName);
                 index.setIndexScore(newIndex);
                 index.setHealthReportId(reportId);
                 index.setCalculatedAt(now);

+ 1 - 1
cfc-web/.last_build_commit

@@ -1 +1 @@
-ee1bf9db1f3b4f8aae22b5202029d009e8bdf252
+35ed064b9440fc86d8000b406a7c0f89bf1552a5

+ 2 - 2
cfc-web/package-lock.json

@@ -1,12 +1,12 @@
 {
   "name": "cfc-web",
-  "version": "1.0.1284",
+  "version": "1.0.1285",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
     "": {
       "name": "cfc-web",
-      "version": "1.0.1284",
+      "version": "1.0.1285",
       "dependencies": {
         "@wangeditor/editor": "^5.1.23",
         "@wangeditor/editor-for-vue": "^1.0.2",

+ 1 - 1
cfc-web/package.json

@@ -1,6 +1,6 @@
 {
   "name": "cfc-web",
-  "version": "1.0.1285",
+  "version": "1.0.1286",
   "private": true,
   "scripts": {
     "dev": "vue-cli-service serve",

+ 17 - 0
cfc-web/public/CHANGELOG-v1.0.md

@@ -4,6 +4,23 @@
 
 ---
 
+## v1.0.1286 (2026-09-02)
+
+### Bug 修复
+- 根治重复API调用——首页合并 family/member/list 与 membership/my、全页面 onLoad/onShow 防双发 + 请求层 3 秒去重 + getChildren 废弃委托
+
+### 其他
+- - 首页 index-home: checkMemberStatus 移入 loggedInInitDone 守卫,onLoad/onShow 用 _onLoadFired 防首次双发
+- - 首页 index-home: loadFamilyFeed 循环前过滤孩子成员,避免对家长发起 getTaskHistory
+- - 全页面: energy/hierarchy/share/survey-history/parent-index/join/notification/onboarding/address/cart/checkout/shop-index/daily-tasks/service-tasks/teacher-home/wealth-cf 统一 _onLoadFired 模式
+- - parent-index: dashboard 降级路径同步设置 familyMembersVisible,避免重复请求 getFamilyMemberList
+- - utils/api.js: 全局请求去重(同 URL+method+body 3 秒窗口复用 Promise),401 重放跳过去重
+- - utils/api.js: getChildren/getUserBadges/getGrowthReport/getTaskHistoryByCategory 等别名统一委托规范函数
+- - 新增 scripts/audit-duplicate-api-calls.js CI 审计脚本(0 error)
+- - AGENTS.md: 新增规则 1-4 + 4a/4b/4c(生命周期双发、同接口单封装、N+1 过滤、getChildren 废弃)
+- 
+
+
 ## v1.0.1285 (2026-09-02)
 
 ### 新功能

+ 18 - 1
cfc-web/public/CHANGELOG.md

@@ -1,6 +1,6 @@
 # 更新日志
 
-> 当前版本: v1.0.1285
+> 当前版本: v1.0.1286
 
 ## 历史版本
 
@@ -8,6 +8,23 @@
 
 ---
 
+## v1.0.1286 (2026-09-02)
+
+### Bug 修复
+- 根治重复API调用——首页合并 family/member/list 与 membership/my、全页面 onLoad/onShow 防双发 + 请求层 3 秒去重 + getChildren 废弃委托
+
+### 其他
+- - 首页 index-home: checkMemberStatus 移入 loggedInInitDone 守卫,onLoad/onShow 用 _onLoadFired 防首次双发
+- - 首页 index-home: loadFamilyFeed 循环前过滤孩子成员,避免对家长发起 getTaskHistory
+- - 全页面: energy/hierarchy/share/survey-history/parent-index/join/notification/onboarding/address/cart/checkout/shop-index/daily-tasks/service-tasks/teacher-home/wealth-cf 统一 _onLoadFired 模式
+- - parent-index: dashboard 降级路径同步设置 familyMembersVisible,避免重复请求 getFamilyMemberList
+- - utils/api.js: 全局请求去重(同 URL+method+body 3 秒窗口复用 Promise),401 重放跳过去重
+- - utils/api.js: getChildren/getUserBadges/getGrowthReport/getTaskHistoryByCategory 等别名统一委托规范函数
+- - 新增 scripts/audit-duplicate-api-calls.js CI 审计脚本(0 error)
+- - AGENTS.md: 新增规则 1-4 + 4a/4b/4c(生命周期双发、同接口单封装、N+1 过滤、getChildren 废弃)
+- 
+
+
 ## v1.0.1285 (2026-09-02)
 
 ### 新功能