feat: 补全 _name 字段公共映射函数,修正实名认证注释
This commit is contained in:
@@ -179,3 +179,51 @@
|
||||
### 验证结果
|
||||
- ✅ `go build ./cmd/api ./cmd/worker` 通过,无任何错误
|
||||
- ✅ `go vet` 无报告
|
||||
|
||||
## [2026-04-14] Task 6: DTO _name 字段补全
|
||||
|
||||
### 概述
|
||||
为所有 Response DTO 中的 `int` 类型状态字段补全对应 `string` 类型 `_name` 字段,并在 Service 层赋值。
|
||||
|
||||
### 常量映射函数(新增)
|
||||
|
||||
**`pkg/constants/constants.go`:**
|
||||
- `GetStatusName(status int) string` — 通用 0=禁用/1=启用
|
||||
- `GetShelfStatusName(status int) string` — 1=上架/2=下架
|
||||
- `GetExchangeStatusName(status int) string` — 换货单状态
|
||||
|
||||
**`pkg/constants/iot.go`:**
|
||||
- `GetIotCardStatusName` — 1=在库, 2=已分销, 3=已激活, 4=已停用
|
||||
- `GetActivationStatusName` — 0=未激活, 1=已激活
|
||||
- `GetRealNameStatusName` — 0=未实名, 1=已实名
|
||||
- `GetNetworkStatusName` — 0=停机, 1=开机
|
||||
- `GetCommissionRecordStatusName` — 1=已冻结/2=解冻中/3=已发放/4=已失效/99=待人工修正
|
||||
- `GetOrderPaymentStatusName` — 1=待支付/2=已支付/3=已取消/4=已退款
|
||||
- `GetOrderCommissionStatusName` — 1=待计算/2=已计算
|
||||
- `GetRefundStatusName` — 1=待审批/2=已通过/3=已拒绝/4=已退回
|
||||
|
||||
### 模块处理情况
|
||||
|
||||
| 模块 | DTO 改动 | Service 赋值位置 | 备注 |
|
||||
|------|---------|-----------------|------|
|
||||
| Account | `AccountResponse` + `status_name` | `toAccountResponse()` | constants 已导入 |
|
||||
| Shop | `ShopResponse` + `status_name` | Create/Update/ListShopResponses(3处)| constants 已导入 |
|
||||
| IotCard | `StandaloneIotCardResponse` + 4个 `_name` 字段 | `toStandaloneResponse()` | status/activation/realname/network |
|
||||
| Order | `OrderResponse` + `commission_status_name` | `buildOrderResponse()` | payment_status 已有 `_text` 字段 |
|
||||
| Package | `PackageResponse` + `status_name`/`shelf_status_name` | `toResponse()` 末尾(agent 覆盖后赋值) | my_package.go 也同步更新(不涉及 service)|
|
||||
| Refund | `RefundResponse` + `status_name` | `buildRefundResponse()` | constants 已导入 |
|
||||
| Device | `DeviceCardBindingResponse` + `status_name` | `device/binding.go` | 新增 constants import |
|
||||
| Asset | `AssetResolveResponse` + `status_name` | `buildDeviceResolveResponse` + `buildCardResolveResponse` | constants 已导入 |
|
||||
| Commission | `CommissionRecordResponse` + `status_name` | 未找到 service 调用(DTO 未被使用,ShopCommissionRecordItem 已有 status_name)| 仅 DTO 更新;同时修正了 description 错误 |
|
||||
| Client Asset | `AssetInfoResponse` + 4个 `_name` 字段 | handler `client_asset.go`(直接赋值)| constants 已导入 |
|
||||
| Client Order | `ClientOrderInfo/ListItem/DetailResponse` + `payment_status_name`; `ClientRechargeInfo` + `status_name` | `client_order/service.go` | 增加 `clientRechargeStatusName` 辅助函数 |
|
||||
| MyPackage | `MyPackageResponse/DetailResponse` + `status_name`/`shelf_status_name`; `MySeriesAllocationResponse` + `status_name` | 未找到 service 调用,仅 DTO 更新 | |
|
||||
|
||||
### 关键发现
|
||||
1. `CommissionRecordResponse.status` description 原先错误(写的 "1:已入账" 但常量是 "1:已冻结"),已修正为正确值
|
||||
2. `ClientRechargeInfo.Status` 使用的是 `rechargeStatusToClientStatus()` 转换后的值(0/1/2),与 RechargeStatus* 常量不同
|
||||
3. 部分 DTO(MyPackage、CommissionRecord)未被 service 层引用,仅更新 DTO 定义
|
||||
4. `DeviceResponse` 和 `ImportTaskResponse` 已经有 `status_name` 和 `status_text` 字段,无需修改
|
||||
|
||||
### 验证结果
|
||||
- ✅ `go build ./cmd/api ./cmd/worker` 通过,无任何错误
|
||||
|
||||
Reference in New Issue
Block a user