diff --git a/docs/integration/frontend-backend.md b/docs/integration/frontend-backend.md index 14e340a..0990bf2 100644 --- a/docs/integration/frontend-backend.md +++ b/docs/integration/frontend-backend.md @@ -4,14 +4,14 @@ ### 1.1 后端 API 统计 -| 领域 | 端点总数 | 已对接 | 未对接 | -|------|----------|--------|--------| -| Account | 11 | 11 | 0 | -| Transaction | 5 | 3 | 2 | -| Ledger | 3 | 0 | 3 | -| Reconciliation | 8 | 4 | 4 | -| Points | 5 | 0 | 5 | -| **总计** | **32** | **18** | **14** | +| 领域 | 端点总数 | 已对接 | 未对接 | 覆盖率 | +|------|----------|--------|--------|--------| +| Account | 11 | 11 | 0 | ✅ 100% | +| Transaction | 5 | 5 | 0 | ✅ 100% | +| Ledger | 3 | 3 | 0 | ✅ 100% | +| Reconciliation | 8 | 8 | 0 | ✅ 100% | +| Points | 5 | 5 | 0 | ✅ 100% | +| **总计** | **32** | **32** | **0** | **✅ 100%** | ### 1.2 前端多余 API @@ -54,36 +54,23 @@ | 后端端点 | 前端方法 | 状态 | 说明 | |----------|----------|------|------| -| POST /transactions/transfer | TransactionAPI.createTransfer | ✅ 已对接 | | -| POST /transactions/deposit | - | ❌ 未对接 | 需添加 createDeposit | -| POST /transactions/withdraw | - | ❌ 未对接 | 需添加 createWithdraw | +| POST /transactions/transfer | TransactionAPI.transfer | ✅ 已对接 | | +| POST /transactions/deposit | TransactionAPI.deposit | ✅ 已对接 | | +| POST /transactions/withdraw | TransactionAPI.withdraw | ✅ 已对接 | | | GET /transactions/:id | TransactionAPI.getTransaction | ✅ 已对接 | | | GET /transactions | TransactionAPI.getTransactions | ✅ 已对接 | | **前端文件**: `src/api/transaction.ts` -**需要补充的前端方法**: -```typescript -// 充值 -static async createDeposit(data: DepositRequest): Promise { - return apiClient.post('/transactions/deposit', data) -} - -// 提现 -static async createWithdraw(data: WithdrawRequest): Promise { - return apiClient.post('/transactions/withdraw', data) -} -``` - ### 2.3 账务 API 对接 | 后端端点 | 前端方法 | 状态 | 说明 | |----------|----------|------|------| -| GET /ledger/subjects | - | ❌ 未对接 | 需创建 ledger.ts | -| GET /ledger/entries/:id | - | ❌ 未对接 | 需创建 ledger.ts | -| GET /ledger/accounts/:id/entries | - | ❌ 未对接 | 需创建 ledger.ts | +| GET /ledger/subjects | LedgerAPI.getSubjects | ✅ 已对接 | | +| GET /ledger/entries/:id | LedgerAPI.getEntry | ✅ 已对接 | | +| GET /ledger/accounts/:id/entries | LedgerAPI.getAccountEntries | ✅ 已对接 | | -**需要创建的前端文件**: `src/api/ledger.ts` +**前端文件**: `src/api/ledger.ts` ### 2.4 对账 API 对接 @@ -94,41 +81,23 @@ static async createWithdraw(data: WithdrawRequest): Promise { | GET /reconciliation/batches/:id/items | ReconciliationAPI.getBatchItems | ✅ 已对接 | | | GET /reconciliation/three-account/:id | ReconciliationAPI.verifyThreeAccounts | ✅ 已对接 | | | POST /reconciliation/adjustments | ReconciliationAPI.createAdjustment | ✅ 已对接 | | -| POST /reconciliation/adjustments/:id/approve | - | ❌ 未对接 | 需添加 approveAdjustment | -| POST /reconciliation/adjustments/:id/reject | - | ❌ 未对接 | 需添加 rejectAdjustment | -| GET /reconciliation/adjustments/pending | - | ❌ 未对接 | 需添加 getPendingAdjustments | +| POST /reconciliation/adjustments/:id/approve | ReconciliationAPI.approveAdjustment | ✅ 已对接 | | +| POST /reconciliation/adjustments/:id/reject | ReconciliationAPI.rejectAdjustment | ✅ 已对接 | | +| GET /reconciliation/adjustments/pending | ReconciliationAPI.getPendingAdjustments | ✅ 已对接 | | **前端文件**: `src/api/reconciliation.ts` -**需要补充的前端方法**: -```typescript -// 审批补录 -static async approveAdjustment(id: number, approver: string): Promise { - return apiClient.post(`/reconciliation/adjustments/${id}/approve`, { approver }) -} - -// 拒绝补录 -static async rejectAdjustment(id: number, approver: string, reason: string): Promise { - return apiClient.post(`/reconciliation/adjustments/${id}/reject`, { approver, reason }) -} - -// 获取待审批补录 -static async getPendingAdjustments(): Promise { - return apiClient.get('/reconciliation/adjustments/pending') -} -``` - ### 2.5 积分 API 对接 | 后端端点 | 前端方法 | 状态 | 说明 | |----------|----------|------|------| -| GET /points/accounts/:id | - | ❌ 未对接 | 需创建 points.ts | -| POST /points/earn | - | ❌ 未对接 | 需创建 points.ts | -| POST /points/spend | - | ❌ 未对接 | 需创建 points.ts | -| POST /points/transfer | - | ❌ 未对接 | 需创建 points.ts | -| GET /points/transactions | - | ❌ 未对接 | 需创建 points.ts | +| GET /points/accounts/:id | PointsAPI.getAccounts | ✅ 已对接 | | +| POST /points/earn | PointsAPI.earnPoints | ✅ 已对接 | | +| POST /points/spend | PointsAPI.spendPoints | ✅ 已对接 | | +| POST /points/transfer | PointsAPI.transferPoints | ✅ 已对接 | | +| GET /points/transactions | PointsAPI.getTransactions | ✅ 已对接 | | -**需要创建的前端文件**: `src/api/points.ts` +**前端文件**: `src/api/points.ts` ## 三、类型定义对照 @@ -235,26 +204,26 @@ export type Direction = 'debit' | 'credit' export type EntryStatus = 'pending' | 'posted' | 'reversed' ``` -## 四、待办事项 +## 四、已完成事项 -### 4.1 高优先级 +### 4.1 API 客户端 (全部完成) -1. ✅ 创建 `src/api/points.ts` - 积分 API 客户端 -2. ✅ 创建 `src/api/ledger.ts` - 账务 API 客户端 -3. 补充 `src/api/transaction.ts` 中的 deposit 和 withdraw 方法 -4. 补充 `src/api/reconciliation.ts` 中的审批相关方法 +- ✅ 创建 `src/api/points.ts` - 积分 API 客户端 +- ✅ 创建 `src/api/ledger.ts` - 账务 API 客户端 +- ✅ 补充 `src/api/transaction.ts` 中的 deposit 和 withdraw 方法 +- ✅ 补充 `src/api/reconciliation.ts` 中的审批相关方法 -### 4.2 中优先级 +### 4.2 类型定义 (全部完成) -1. 添加 `src/types/points.ts` - 积分类型定义 -2. 添加 `src/types/ledger.ts` - 账务类型定义 -3. 更新前端界面支持新的 API +- ✅ 添加 `src/types/points.ts` - 积分类型定义 +- ✅ 添加 `src/types/ledger.ts` - 账务类型定义 -### 4.3 低优先级 +### 4.3 后续优化建议 -1. 后端补充前端多余 API 的实现 +1. 更新前端界面以支持新的 API 2. 添加 API 版本管理 3. 添加 API 文档自动生成(OpenAPI/Swagger) +4. 后端补充扩展 API(如交易统计、银行流水查询等) ## 五、接口规范