# Special Check Family Asset Liability Detail Redesign Backend Implementation Plan

> **For agentic workers:** REQUIRED: Use superpowers:subagent-driven-development (if subagents available) or superpowers:executing-plans to implement this plan. Steps use checkbox (`- [ ]`) syntax for tracking.

**Goal:** 在不改动专项核查详情接口契约的前提下，确认现有后端返回仍能完整支撑展开区改版，并补足回归验证与后端记录。

**Architecture:** 本次设计明确“不新增后端字段、不调整控制器、服务和 Mapper 口径”。后端实施只围绕现有 `summary + incomeDetail + assetDetail + debtDetail` 结构做回归锁定：通过增强服务层和 SQL 结构测试，确认前端改版所需的总额、风险等级和原始条目字段已完整存在；若测试通过，则不修改生产代码。

**Tech Stack:** Java 21, Spring Boot 3, MyBatis XML, Maven, JUnit 5

---

## File Map

- Modify: `ccdi-project/src/test/java/com/ruoyi/ccdi/project/service/impl/CcdiProjectSpecialCheckServiceImplTest.java`
  - 锁定详情 `summary` 与前端改版所需字段的一致性
- Modify: `ccdi-project/src/test/java/com/ruoyi/ccdi/project/mapper/CcdiProjectSpecialCheckMapperDetailSqlTest.java`
  - 锁定明细 SQL 继续返回前端聚合所需原始字段
- Create: `docs/reports/implementation/2026-03-25-special-check-family-asset-liability-detail-redesign-backend-record.md`
  - 记录本次后端为零生产代码改动的边界
- Create: `docs/tests/records/2026-03-25-special-check-family-asset-liability-detail-redesign-backend-verification.md`
  - 记录后端回归验证结果

### Task 1: 锁定后端详情契约回归

**Files:**
- Modify: `ccdi-project/src/test/java/com/ruoyi/ccdi/project/service/impl/CcdiProjectSpecialCheckServiceImplTest.java`
- Modify: `ccdi-project/src/test/java/com/ruoyi/ccdi/project/mapper/CcdiProjectSpecialCheckMapperDetailSqlTest.java`

- [ ] **Step 1: Write the failing test**

在现有测试基础上补充以下断言：

- `summary` 中的 `totalIncome / totalDebt / totalAsset / riskLevelCode / riskLevelName` 可直接复用到前端改版
- SQL 继续返回 `asset_main_type / asset_sub_type / current_value`
- SQL 继续返回 `debt_main_type / debt_sub_type / principal_balance`
- 不引入新的后端聚合字段，不依赖额外 VO

- [ ] **Step 2: Run test to verify it fails**

Run:

```bash
mvn test -pl ccdi-project -Dtest=CcdiProjectSpecialCheckServiceImplTest,CcdiProjectSpecialCheckMapperDetailSqlTest
```

Expected:

- `FAIL`
- 原因是新增回归断言尚未补齐

- [ ] **Step 3: Write minimal implementation**

只修改测试，不动生产代码：

- 在服务层测试中补充 `summary` 字段复用断言
- 在 Mapper SQL 测试中补充类型字段与金额字段断言
- 明确当前接口足以支撑前端按类型聚合与风险结论展示

- [ ] **Step 4: Run test to verify it passes**

Run:

```bash
mvn test -pl ccdi-project -Dtest=CcdiProjectSpecialCheckServiceImplTest,CcdiProjectSpecialCheckMapperDetailSqlTest
```

Expected:

- `PASS`

- [ ] **Step 5: Commit**

```bash
git add ccdi-project/src/test/java/com/ruoyi/ccdi/project/service/impl/CcdiProjectSpecialCheckServiceImplTest.java ccdi-project/src/test/java/com/ruoyi/ccdi/project/mapper/CcdiProjectSpecialCheckMapperDetailSqlTest.java
git commit -m "补充专项核查展开区后端回归测试"
```

### Task 2: 完成后端验证与记录

**Files:**
- Create: `docs/reports/implementation/2026-03-25-special-check-family-asset-liability-detail-redesign-backend-record.md`
- Create: `docs/tests/records/2026-03-25-special-check-family-asset-liability-detail-redesign-backend-verification.md`

- [ ] **Step 1: Write the failing test**

这里不新增代码断言，先整理验证目标：

- 后端生产代码零变更
- 详情契约继续满足前端改版输入要求
- 聚焦专项核查详情相关测试，不扩大到无关模块

- [ ] **Step 2: Run test to verify it fails**

Run:

```bash
mvn test -pl ccdi-project -Dtest=CcdiProjectSpecialCheckServiceImplTest,CcdiProjectSpecialCheckMapperDetailSqlTest,CcdiProjectSpecialCheckControllerTest
```

Expected:

- 在测试与文档未补齐前，至少一项为 `FAIL` 或文档缺失

- [ ] **Step 3: Write minimal implementation**

补齐两份文档：

- 后端实施记录写清：
  - 本次不修改控制器、服务、Mapper、VO
  - 仅增强回归测试，确认接口可继续支撑前端改版
- 后端验证记录写清：
  - 运行命令
  - 通过结果
  - “零生产代码改动”的核对结论

- [ ] **Step 4: Run test to verify it passes**

Run:

```bash
mvn test -pl ccdi-project -Dtest=CcdiProjectSpecialCheckServiceImplTest,CcdiProjectSpecialCheckMapperDetailSqlTest,CcdiProjectSpecialCheckControllerTest
```

Expected:

- `PASS`
- 工作区内无 `ccdi-project/src/main` 生产代码改动

- [ ] **Step 5: Commit**

```bash
git add docs/reports/implementation/2026-03-25-special-check-family-asset-liability-detail-redesign-backend-record.md docs/tests/records/2026-03-25-special-check-family-asset-liability-detail-redesign-backend-verification.md
git commit -m "补充专项核查展开区后端验证记录"
```
