docs: 更新前后端对接清单 - 100%覆盖率

This commit is contained in:
tangweijie 2026-01-05 18:18:05 +08:00
parent 1460187516
commit 2243e9caa6

View File

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