Procházet zdrojové kódy

docs: 菌群计划文档回填实施状态并记录偏差①修复

- 计划附录偏差①标记已修复:文件迁移/pages.json/主页跳转/验证证据
- 头部实施状态、文件结构表、Task 10/11 注记、Task 16 期望值(3→4) 同步更新
- PROJECT-OVERVIEW 条目更新为 health 分包 4 页架构齐备

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

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Xiaogang Liao před 3 týdny
rodič
revize
7cb34880d2

+ 1 - 1
docs/superpowers/PROJECT-OVERVIEW.md

@@ -370,7 +370,7 @@
 | `2026-07-20-langgraph-phase2.md` | 🔄 合并至 comprehensive plan | LangGraph Phase 2 |
 | `2026-07-20-langgraph-phase3.md` | 🔄 合并至 comprehensive plan | LangGraph Phase 3 |
 | `2026-07-20-langgraph-phase4.md` | 🔄 合并至 comprehensive plan | LangGraph Phase 4 |
-| `2026-07-17-flora-microbiome-report-implementation.md` | ✅ 已完成(4页面 1214行 + HealthKnowledgeBase后端) | 菌群报告重构 |
+| `2026-07-17-flora-microbiome-report-implementation.md` | ✅ 已完成(health 分包4页架构齐备:detail/species/risks/foods + HealthKnowledgeBase后端;foods 页 2026-08-22 自 growth 迁移归位,偏差①已修复) | 菌群报告重构 |
 | `2026-07-16-first-login-auto-complete-plan.md` | ✅ 已实施(login.vue + user-edit.vue均已完成) | 首次登录优化 |
 | `2026-07-14-family-promotion.md` | ✅ 已完成(推广中心 6 页面 + 27 后端文件) | 家庭推广体系 |
 | `2026-07-13-dan-assessment-phase2-5.md` | 🟡 计划中 | DAN测评优化 |

+ 88 - 50
docs/superpowers/plans/2026-07-17-flora-microbiome-report-implementation.md

@@ -8,6 +8,8 @@
 
 **Tech Stack:** Java 8 + Spring Boot 2.7.18 + MyBatis-Plus / uni-app (Vue 2 Options API) / WeChat Mini-Program / Playwright E2E
 
+> **✅ 实施状态(2026-08-22 回填核实):** 全部任务已完成并通过代码核实(后端 entity/mapper/service/controller、迁移98、`/report/edit`、前端组件与页面、E2E spec 均在仓库中)。初版存在的 1 处落地路径偏差(食物推荐页)已于同日修复归位,详见文末「附录:实施偏差记录」。文中代码块为计划原稿,实际代码以仓库为准。
+
 ---
 
 ## 文件结构总览
@@ -30,9 +32,9 @@
 | `components/health-knowledge-popup.vue` | NEW | 通用知识库弹出框组件 |
 | `pages/health/gut-flora-detail.vue` | REWRITE | 主页(评分+手风琴+指标+编辑) |
 | `pages/health/gut-flora-species-detail.vue` | NEW | 菌群详情(12 Tab + 卡片) |
-| `pages/health/gut-flora-foods-detail.vue` | NEW | 食物推荐(筛选+卡片+编辑) |
+| `pages/health/gut-flora-foods-detail.vue` | NEW | 食物推荐(筛选+卡片+编辑)。2026-08-22 已自 `pages/growth/foods-detail.vue` 迁移归位(附录偏差①已修复) |
 | `pages/health/gut-flora-risks-detail.vue` | NEW | 疾病风险(分类+卡片+编辑) |
-| `pages.json` | MODIFY | 注册 3 个新页面 |
+| `pages.json` | MODIFY | 注册 gut-flora-species-detail / gut-flora-risks-detail / gut-flora-foods-detail,4 页架构齐备 |
 | `utils/api.js` | MODIFY | 新增 editHealthReport、queryKnowledgeBase、batchQueryKnowledgeBase |
 
 ### 测试
@@ -47,7 +49,7 @@
 **Files:**
 - Create: `cfc-backend/src/main/java/com/etotem/cfc/entity/HealthKnowledgeBase.java`
 
-- [ ] **Step 1: 创建实体类**
+- [x] **Step 1: 创建实体类**
 
 ```java
 package com.etotem.cfc.entity;
@@ -98,12 +100,12 @@ public class HealthKnowledgeBase implements Serializable {
 }
 ```
 
-- [ ] **Step 2: 编译验证**
+- [x] **Step 2: 编译验证**
 
 Run: `cd /sc-data/cfc/cfc-backend && mvn clean compile`
 Expected: BUILD SUCCESS
 
-- [ ] **Step 3: Commit**
+- [x] **Step 3: Commit**
 
 ```bash
 cd /sc-data/cfc
@@ -118,7 +120,7 @@ git commit -m "feat(backend): add HealthKnowledgeBase entity"
 **Files:**
 - Create: `cfc-backend/src/main/java/com/etotem/cfc/mapper/HealthKnowledgeBaseMapper.java`
 
-- [ ] **Step 1: 创建 Mapper 接口**
+- [x] **Step 1: 创建 Mapper 接口**
 
 ```java
 package com.etotem.cfc.mapper;
@@ -130,12 +132,12 @@ public interface HealthKnowledgeBaseMapper extends BaseMapper<HealthKnowledgeBas
 }
 ```
 
-- [ ] **Step 2: 编译验证**
+- [x] **Step 2: 编译验证**
 
 Run: `cd /sc-data/cfc/cfc-backend && mvn clean compile`
 Expected: BUILD SUCCESS
 
-- [ ] **Step 3: Commit**
+- [x] **Step 3: Commit**
 
 ```bash
 cd /sc-data/cfc
@@ -150,7 +152,7 @@ git commit -m "feat(backend): add HealthKnowledgeBaseMapper"
 **Files:**
 - Create: `cfc-backend/src/main/java/com/etotem/cfc/service/HealthKnowledgeBaseService.java`
 
-- [ ] **Step 1: 创建 Service 类**
+- [x] **Step 1: 创建 Service 类**
 
 ```java
 package com.etotem.cfc.service;
@@ -214,12 +216,12 @@ public class HealthKnowledgeBaseService {
 }
 ```
 
-- [ ] **Step 2: 编译验证**
+- [x] **Step 2: 编译验证**
 
 Run: `cd /sc-data/cfc/cfc-backend && mvn clean compile`
 Expected: BUILD SUCCESS
 
-- [ ] **Step 3: Commit**
+- [x] **Step 3: Commit**
 
 ```bash
 cd /sc-data/cfc
@@ -235,12 +237,12 @@ git commit -m "feat(backend): add HealthKnowledgeBaseService (query + batchQuery
 - Create: `cfc-backend/src/main/java/com/etotem/cfc/controller/HealthKnowledgeBaseController.java`
 - Bean 名冲突检查: `grep -rn 'class HealthKnowledgeBaseController' src/main/java/com/etotem/cfc/controller/` 确保无重名
 
-- [ ] **Step 1: 检查路由重复**
+- [x] **Step 1: 检查路由重复**
 
 Run: `cd /sc-data/cfc/cfc-backend && grep -rn '@Mapping' src/main/java/com/etotem/cfc/controller/ | grep -oP '@\w+Mapping\("\K[^"]*' | sort -u`
 Expected: /api/health/knowledge/query 未出现
 
-- [ ] **Step 2: 创建 Controller**
+- [x] **Step 2: 创建 Controller**
 
 ```java
 package com.etotem.cfc.controller;
@@ -295,12 +297,12 @@ public class HealthKnowledgeBaseController {
 }
 ```
 
-- [ ] **Step 3: 编译验证**
+- [x] **Step 3: 编译验证**
 
 Run: `cd /sc-data/cfc/cfc-backend && mvn clean compile`
 Expected: BUILD SUCCESS
 
-- [ ] **Step 4: Commit**
+- [x] **Step 4: Commit**
 
 ```bash
 cd /sc-data/cfc
@@ -316,7 +318,7 @@ git commit -m "feat(backend): add HealthKnowledgeBaseController (query + batch-q
 - Modify: `cfc-backend/src/main/java/com/etotem/cfc/config/DatabaseInitializer.java`
 - Modify: `cfc-backend/src/main/resources/schema.sql`
 
-- [ ] **Step 1: 在 DatabaseInitializer 添加迁移 93**
+- [x] **Step 1: 在 DatabaseInitializer 添加迁移 93**
 
 在 `runMigrations()` 末尾(`// 迁移92` 之后)追加:
 
@@ -345,7 +347,7 @@ git commit -m "feat(backend): add HealthKnowledgeBaseController (query + batch-q
 
 **Location detail:** 在 DatabaseInitializer.java 末尾的 `runMigrations()` 中,最后一个 try-catch 之后、`}` 闭合之前插入。当前第 5884 行附近。
 
-- [ ] **Step 2: 在 schema.sql 末尾追加 DDL**
+- [x] **Step 2: 在 schema.sql 末尾追加 DDL**
 
 ```sql
 -- 健康知识库 — 菌属/营养素/指标说明
@@ -365,12 +367,12 @@ CREATE TABLE IF NOT EXISTS `health_knowledge_base` (
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='健康知识库 - 菌属/营养素/指标说明';
 ```
 
-- [ ] **Step 3: 编译验证**
+- [x] **Step 3: 编译验证**
 
 Run: `cd /sc-data/cfc/cfc-backend && mvn clean compile`
 Expected: BUILD SUCCESS
 
-- [ ] **Step 4: Commit**
+- [x] **Step 4: Commit**
 
 ```bash
 cd /sc-data/cfc
@@ -387,7 +389,7 @@ git commit -m "feat(backend): add health_knowledge_base table (migration 93)"
 - Modify: `cfc-backend/src/main/java/com/etotem/cfc/controller/HealthReportController.java`
 - Modify: `cfc-backend/src/main/java/com/etotem/cfc/service/HealthReportService.java`
 
-- [ ] **Step 1: 在 Controller 中新增编辑端点**
+- [x] **Step 1: 在 Controller 中新增编辑端点**
 
 在 `HealthReportController` 中(`getReportDetail` 方法之后)追加:
 
@@ -424,7 +426,7 @@ git commit -m "feat(backend): add health_knowledge_base table (migration 93)"
     }
 ```
 
-- [ ] **Step 2: 在 Service 中新增 `updateReportFromPayload`**
+- [x] **Step 2: 在 Service 中新增 `updateReportFromPayload`**
 
 ```java
     /**
@@ -541,7 +543,7 @@ git commit -m "feat(backend): add health_knowledge_base table (migration 93)"
     }
 ```
 
-- [ ] **Step 3: 在 Controller 上方追加所需的 import**
+- [x] **Step 3: 在 Controller 上方追加所需的 import**
 
 确认文件顶部已有:
 ```java
@@ -554,7 +556,7 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 ```
 
-- [ ] **Step 4: 确保 HealthReportService 中有需要的 Mapper 注入**
+- [x] **Step 4: 确保 HealthReportService 中有需要的 Mapper 注入**
 
 在 `HealthReportService.java` 中确认以下字段已存在,若不存在则添加:
 ```java
@@ -574,12 +576,12 @@ import org.springframework.transaction.annotation.Transactional;
     private DimensionScoreService dimensionScoreService;
 ```
 
-- [ ] **Step 5: 编译验证**
+- [x] **Step 5: 编译验证**
 
 Run: `cd /sc-data/cfc/cfc-backend && mvn clean compile`
 Expected: BUILD SUCCESS
 
-- [ ] **Step 6: Commit**
+- [x] **Step 6: Commit**
 
 ```bash
 cd /sc-data/cfc
@@ -595,7 +597,7 @@ git commit -m "feat(backend): add POST /api/health/report/edit + updateReportFro
 - Create: `cfc-backend/src/main/java/com/etotem/cfc/service/KnowledgeBaseDataImporter.java`
 - 数据源: `docs/superpowers/refs/501999942-某人.json`, `530010234-侯.json`, `儿童示例.json`
 
-- [ ] **Step 1: 创建数据导入 Service(一次性工具)**
+- [x] **Step 1: 创建数据导入 Service(一次性工具)**
 
 ```java
 package com.etotem.cfc.service;
@@ -756,7 +758,7 @@ public class KnowledgeBaseDataImporter {
 }
 ```
 
-- [ ] **Step 2: 创建资源目录并将参考 JSON 复制到 resources/data/refs/**
+- [x] **Step 2: 创建资源目录并将参考 JSON 复制到 resources/data/refs/**
 
 ```bash
 mkdir -p /sc-data/cfc/cfc-backend/src/main/resources/data/refs
@@ -765,12 +767,12 @@ cp /sc-data/cfc/docs/superpowers/refs/530010234-侯.json /sc-data/cfc/cfc-backen
 cp /sc-data/cfc/docs/superpowers/refs/儿童示例.json /sc-data/cfc/cfc-backend/src/main/resources/data/refs/
 ```
 
-- [ ] **Step 3: 编译验证**
+- [x] **Step 3: 编译验证**
 
 Run: `cd /sc-data/cfc/cfc-backend && mvn clean compile`
 Expected: BUILD SUCCESS
 
-- [ ] **Step 4: Commit**
+- [x] **Step 4: Commit**
 
 ```bash
 cd /sc-data/cfc
@@ -782,7 +784,7 @@ git commit -m "feat(backend): add KnowledgeBaseDataImporter + ref JSONs"
 
 ### Task 8: 前端 — api.js 新增方法
 
-- [ ] **Step 1: 在 utils/api.js 中追加 3 个方法**(在 `getReportDetail` 附近,约第 1515 行)
+- [x] **Step 1: 在 utils/api.js 中追加 3 个方法**(在 `getReportDetail` 附近,约第 1515 行)
 
 ```javascript
 export const editHealthReport = (reportId, payload, subjectId) => request('/api/health/report/edit', 'POST', { reportId, payload, subjectId })
@@ -792,7 +794,7 @@ export const queryKnowledgeBase = (itemType, itemName) => request('/api/health/k
 export const batchQueryKnowledgeBase = (queries) => request('/api/health/knowledge/batch-query', 'POST', { queries })
 ```
 
-- [ ] **Step 2: Commit**
+- [x] **Step 2: Commit**
 
 ```bash
 cd /sc-data/cfc
@@ -807,7 +809,7 @@ git commit -m "feat(frontend): add editHealthReport, queryKnowledgeBase, batchQu
 **Files:**
 - Create: `cfc-frontend/components/health-knowledge-popup.vue`
 
-- [ ] **Step 1: 创建弹出框组件**
+- [x] **Step 1: 创建弹出框组件**
 
 ```vue
 <template>
@@ -920,7 +922,7 @@ export default {
 </style>
 ```
 
-- [ ] **Step 2: Commit**
+- [x] **Step 2: Commit**
 
 ```bash
 cd /sc-data/cfc
@@ -932,7 +934,9 @@ git commit -m "feat(frontend): add health-knowledge-popup component"
 
 ### Task 10: 前端 — pages.json 注册 3 个新页面
 
-- [ ] **Step 1: 在 pages.json 中 health 分组内追加 3 条路径**
+> ✅ **实施记录(2026-08-22 更新):** 初版仅注册 species/risks 两条;同日已补齐——`gut-flora-foods-detail` 注册至 health 分包(页面自 growth/foods-detail 迁移而来,见附录偏差①)。现 pages.json 含全部 3 条 gut-flora 子页 + 主页,与计划一致。
+
+- [x] **Step 1: 在 pages.json 中 health 分组内追加 3 条路径**
 
 在 `"path": "pages/health/gut-flora-detail"` 条目之后追加:
 
@@ -957,7 +961,7 @@ git commit -m "feat(frontend): add health-knowledge-popup component"
     }
 ```
 
-- [ ] **Step 2: Commit**
+- [x] **Step 2: Commit**
 
 ```bash
 cd /sc-data/cfc
@@ -969,10 +973,12 @@ git commit -m "feat(frontend): register 3 new health detail pages in pages.json"
 
 ### Task 11: 前端 — 食物推荐详情页
 
+> ✅ **实施记录(2026-08-22 更新):** 页面现已存在于计划路径 `cfc-frontend/pages/health/gut-flora-foods-detail.vue`——由 `pages/growth/foods-detail.vue` 经 git mv 迁移归位,功能含知识库营养数据合并增强;主页跳转已同步更新。详见附录偏差①修复记录。
+
 **Files:**
 - Create: `cfc-frontend/pages/health/gut-flora-foods-detail.vue`
 
-- [ ] **Step 1: 创建页面(最简单页面,先做以验证编辑流)**
+- [x] **Step 1: 创建页面(最简单页面,先做以验证编辑流)**
 
 ```vue
 <template>
@@ -1161,7 +1167,7 @@ export default {
 </style>
 ```
 
-- [ ] **Step 2: Commit**
+- [x] **Step 2: Commit**
 
 ```bash
 cd /sc-data/cfc
@@ -1176,7 +1182,7 @@ git commit -m "feat(frontend): add gut-flora-foods-detail page"
 **Files:**
 - Create: `cfc-frontend/pages/health/gut-flora-risks-detail.vue`
 
-- [ ] **Step 1: 创建页面**
+- [x] **Step 1: 创建页面**
 
 ```vue
 <template>
@@ -1390,7 +1396,7 @@ export default {
 </style>
 ```
 
-- [ ] **Step 2: Commit**
+- [x] **Step 2: Commit**
 
 ```bash
 cd /sc-data/cfc
@@ -1405,7 +1411,7 @@ git commit -m "feat(frontend): add gut-flora-risks-detail page with knowledge po
 **Files:**
 - Create: `cfc-frontend/pages/health/gut-flora-species-detail.vue`
 
-- [ ] **Step 1: 创建页面**
+- [x] **Step 1: 创建页面**
 
 ```vue
 <template>
@@ -1615,7 +1621,7 @@ export default {
 </style>
 ```
 
-- [ ] **Step 2: Commit**
+- [x] **Step 2: Commit**
 
 ```bash
 cd /sc-data/cfc
@@ -1630,7 +1636,7 @@ git commit -m "feat(frontend): add gut-flora-species-detail page (12 tabs + colo
 **Files:**
 - Modify: `cfc-frontend/pages/health/gut-flora-detail.vue`(完全重写)
 
-- [ ] **Step 1: 重写主页 — 完整长 scroll + 评分圆环 + 手风琴 + 颜色箭头 + 知识库 + 编辑模式**
+- [x] **Step 1: 重写主页 — 完整长 scroll + 评分圆环 + 手风琴 + 颜色箭头 + 知识库 + 编辑模式**
 
 ```vue
 <template>
@@ -2030,7 +2036,7 @@ export default {
 </style>
 ```
 
-- [ ] **Step 2: Commit**
+- [x] **Step 2: Commit**
 
 ```bash
 cd /sc-data/cfc
@@ -2045,7 +2051,7 @@ git commit -m "feat(frontend): rewrite gut-flora-detail with full data, accordio
 **Files:**
 - Modify: `tests/e2e/flora-microbiome-flow.spec.js`
 
-- [ ] **Step 1: 检查并更新现有 E2E 测试**
+- [x] **Step 1: 检查并更新现有 E2E 测试**
 
 读取现有测试文件,确认 `.kb-link`、`.kb-popup-overlay`、`.flora-name` 等新选择器是否涵盖。若无,添加新断言并在关键操作步骤增加超时。
 
@@ -2061,7 +2067,7 @@ git commit -m "feat(frontend): rewrite gut-flora-detail with full data, accordio
 
 为 Playwright 配置 viewport: `{ width: 375, height: 667 }`(iPhone 6/7/8 尺寸)
 
-- [ ] **Step 2: Commit**
+- [x] **Step 2: Commit**
 
 ```bash
 cd /sc-data/cfc
@@ -2073,22 +2079,22 @@ git commit -m "test(e2e): update flora-microbiome-flow tests for restructured pa
 
 ### Task 16: 最终验证
 
-- [ ] **Step 1: 后端编译**
+- [x] **Step 1: 后端编译**
 
 Run: `cd /sc-data/cfc/cfc-backend && mvn clean compile`
 Expected: BUILD SUCCESS
 
-- [ ] **Step 2: 检查小程序项目完整注册**
+- [x] **Step 2: 检查小程序项目完整注册**
 
 Run: `cd /sc-data/cfc && grep -c 'gut-flora' cfc-frontend/pages.json`
-Expected: 4(gut-flora-detail, gut-flora-species-detail, gut-flora-foods-detail, gut-flora-risks-detail
+Expected: 4(gut-flora-detail, gut-flora-species-detail, gut-flora-risks-detail, gut-flora-foods-detail;✅ 2026-08-22 偏差①修复后达标
 
-- [ ] **Step 3: 检查所有新文件**
+- [x] **Step 3: 检查所有新文件**
 
 Run: `cd /sc-data/cfc && git ls-files -- 'cfc-backend/' 'cfc-frontend/' | grep -E '(KnowledgeBase|gut-flora|knowledge-popup)'`
 Expected: 所有新文件已跟踪
 
-- [ ] **Step 4: 最终 push**
+- [x] **Step 4: 最终 push**
 
 ```bash
 cd /sc-data/cfc
@@ -2140,3 +2146,35 @@ Two execution options:
 2. **Inline Execution** — Execute tasks in this session with checkpoints
 
 Which approach?
+
+---
+
+## 附录:实施偏差记录(2026-08-22 核实回填)
+
+### 偏差① 食物推荐页落地路径变更 —— ✅ 已修复(2026-08-22)
+
+**偏差原状**:初版实施将食物推荐页落在 `pages/growth/foods-detail.vue`,未按计划创建 `pages/health/gut-flora-foods-detail.vue`。
+
+**修复动作(2026-08-22)**:
+
+| 项 | 修复内容 |
+|----|---------|
+| 文件迁移 | `git mv cfc-frontend/pages/growth/foods-detail.vue cfc-frontend/pages/health/gut-flora-foods-detail.vue`(git 历史保留) |
+| pages.json | 移除 growth 分包注册;health 分包新增 `gut-flora-foods-detail`(gut-flora-risks-detail 之后),4 页架构齐备 |
+| 主页入口 | gut-flora-detail.vue `goToFoods()` 改跳 `/pages/health/gut-flora-foods-detail?reportId=` |
+| 功能保留 | 知识库「食物库」营养数据合并增强(getKnowledgeSection)原样保留 |
+| 验证 | script 块 node --check 通过;pages.json JSON 校验通过;全仓无 `growth/foods-detail` 残留引用;E2E spec 无 foods 路径断言、无需变更 |
+
+注:`growth/caution-detail`(戒备食材页)与 `diet/index.vue`(独立饮食推荐系统)不属菌群报告流,维持原位。
+
+### 偏差② 迁移编号变化
+
+计划编写时为「迁移93」,实际落地时该编号已被其它迁移占用,health_knowledge_base 表创建落在 **迁移98**(DatabaseInitializer.java:6795,schema.sql:3293 已同步)。
+
+### 核实证据清单
+
+- 后端四件套存在:`entity/HealthKnowledgeBase.java`、`mapper/HealthKnowledgeBaseMapper.java`、`service/HealthKnowledgeBaseService.java`、`controller/HealthKnowledgeBaseController.java`(且扩展了 v3/unified 批量端点)
+- 编辑链路存在:`HealthReportController` `/report/edit`(L357) + `updateReportFromPayload` + `DimensionScoreService.refreshFromGutReport`
+- 前端存在:`components/health-knowledge-popup.vue`、`gut-flora-detail.vue`(重写版)、`gut-flora-species-detail.vue`、`gut-flora-risks-detail.vue`、api.js 三个方法(L1941-1947)
+- E2E 存在:`tests/e2e/flora-microbiome-flow.spec.js`
+- 五维页面接入:身(body-detail 营养模块+肠胃健康评分+菌群评分面板)、心(mind-detail 情绪与肠胃 + `/api/mind/neurotransmitters`)、智(wisdom-detail 肠胃与认知 + `/api/wisdom/gut-cognition`);行/富无菌群业务(符合预期)