docs(03-01): 完成设备体系数据基础层计划
- 创建 03-01-SUMMARY.md - 更新 STATE.md(进度推进至 Plan 2) - 更新 ROADMAP.md(Phase 3 进行中) - 标记 REQUIREMENTS.md(DEVICE-01/02/03 完成)
This commit is contained in:
@@ -47,9 +47,9 @@
|
||||
|
||||
### DEVICE — 设备体系完善(方案 D)
|
||||
|
||||
- [ ] **DEVICE-01**: 设备模型字段扩展 — DB 迁移新增 `online_status / last_online_time / software_version / switch_mode / last_gateway_sync_at`
|
||||
- [ ] **DEVICE-02**: Gateway sync-info 同步接口对接 — `internal/gateway/device.go` 新增 `SyncDeviceInfo()` 方法
|
||||
- [ ] **DEVICE-03**: `tb_device_sim_binding` 新增 `is_current` 字段 — DB 迁移 + Model + 更新逻辑
|
||||
- [x] **DEVICE-01**: 设备模型字段扩展 — DB 迁移新增 `online_status / last_online_time / software_version / switch_mode / last_gateway_sync_at`
|
||||
- [x] **DEVICE-02**: Gateway sync-info 同步接口对接 — `internal/gateway/device.go` 新增 `SyncDeviceInfo()` 方法
|
||||
- [x] **DEVICE-03**: `tb_device_sim_binding` 新增 `is_current` 字段 — DB 迁移 + Model + 更新逻辑
|
||||
- [ ] **DEVICE-04**: 设备 Refresh + 详情接入 sync-info — `RefreshDevice()` 在刷新卡数据后调用 `SyncDeviceInfo()`,更新设备在线状态/固件版本/当前卡标识
|
||||
|
||||
### REFUND — 退款完整功能(方案 I)
|
||||
@@ -142,9 +142,9 @@
|
||||
| POLL-02 | Phase 2 | Complete |
|
||||
| POLL-03 | Phase 2 | Complete |
|
||||
| POLL-04 | Phase 2 | Complete |
|
||||
| DEVICE-01 | Phase 3 | Pending |
|
||||
| DEVICE-02 | Phase 3 | Pending |
|
||||
| DEVICE-03 | Phase 3 | Pending |
|
||||
| DEVICE-01 | Phase 3 | Complete |
|
||||
| DEVICE-02 | Phase 3 | Complete |
|
||||
| DEVICE-03 | Phase 3 | Complete |
|
||||
| DEVICE-04 | Phase 3 | Pending |
|
||||
| REFUND-01 | Phase 4 | Pending |
|
||||
| REFUND-02 | Phase 4 | Pending |
|
||||
|
||||
@@ -73,7 +73,7 @@ Plans:
|
||||
**Plans**: 2 plans
|
||||
|
||||
Plans:
|
||||
- [ ] 03-01-PLAN.md — DEVICE-01/02/03:DB 迁移 + 模型扩展 + Gateway SyncDeviceInfo + DTO 字段(Wave 1)
|
||||
- [x] 03-01-PLAN.md — DEVICE-01/02/03:DB 迁移 + 模型扩展 + Gateway SyncDeviceInfo + DTO 字段(Wave 1)
|
||||
- [ ] 03-02-PLAN.md — DEVICE-04:Asset Service 接入 sync-info,Refresh 追加设备状态同步(Wave 2)
|
||||
|
||||
---
|
||||
@@ -128,7 +128,7 @@ Plans:
|
||||
|-------|----------------|--------|-----------|
|
||||
| 1. P0 紧急修复 | 5/5 | Complete | 2026-03-27 |
|
||||
| 2. 权限/财务/实名/轮询修复 | 2/2 | Complete | 2026-03-28 |
|
||||
| 3. 设备体系完善 | 0/TBD | Not started | - |
|
||||
| 3. 设备体系完善 | 1/2 | In Progress| |
|
||||
| 4. 退款 + 支付 + 运营修复 | 0/TBD | Not started | - |
|
||||
| 5. 代码质量清理 | 0/TBD | Not started | - |
|
||||
| 6. 流量体系改革(低峰期)| 0/TBD | Not started | - |
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
gsd_state_version: 1.0
|
||||
milestone: v1.0
|
||||
milestone_name: milestone
|
||||
status: active
|
||||
last_updated: "2026-03-28T02:52:41.931Z"
|
||||
status: unknown
|
||||
last_updated: "2026-03-28T03:33:58.201Z"
|
||||
progress:
|
||||
total_phases: 6
|
||||
completed_phases: 2
|
||||
total_plans: 7
|
||||
completed_plans: 7
|
||||
total_plans: 9
|
||||
completed_plans: 8
|
||||
---
|
||||
|
||||
# Project State — 君鸿卡管系统
|
||||
@@ -21,6 +21,8 @@ progress:
|
||||
|
||||
## Current Position
|
||||
|
||||
Phase: 03 (device-system) — EXECUTING
|
||||
Plan: 2 of 2
|
||||
| Field | Value |
|
||||
|-------|-------|
|
||||
| **Current Phase** | 3 — 设备体系完善 |
|
||||
@@ -40,7 +42,7 @@ Progress: [ 1 ]──[ 2 ]──[ 3 ]──[ 4 ]──[ 5 ]──[ 6 ]
|
||||
|
||||
**Core Value:** 业务链路完整可用——代理能采购分配卡/设备,C端客户能充值购包激活套餐,佣金能正确计算并可提现。这条主链路必须端到端跑通。
|
||||
|
||||
**Current Focus:** Phase 03 — 设备体系完善
|
||||
**Current Focus:** Phase 03 — device-system
|
||||
|
||||
---
|
||||
|
||||
@@ -69,6 +71,7 @@ Progress: [ 1 ]──[ 2 ]──[ 3 ]──[ 4 ]──[ 5 ]──[ 6 ]
|
||||
| Phases complete | 2/6 |
|
||||
|
||||
---
|
||||
| Phase 03-device-system P01 | 8min | 2 tasks | 10 files |
|
||||
|
||||
## Execution Log
|
||||
|
||||
|
||||
93
.planning/phases/03-device-system/03-01-SUMMARY.md
Normal file
93
.planning/phases/03-device-system/03-01-SUMMARY.md
Normal file
@@ -0,0 +1,93 @@
|
||||
---
|
||||
phase: 03-device-system
|
||||
plan: "01"
|
||||
subsystem: device
|
||||
tags: [migration, model, gateway, dto]
|
||||
dependency_graph:
|
||||
requires: []
|
||||
provides:
|
||||
- tb_device 5个 sync-info 存储字段
|
||||
- tb_device_sim_binding.is_current 字段
|
||||
- Gateway SyncDeviceInfo() 方法
|
||||
- DeviceResponse 5个新字段
|
||||
- DeviceCardBindingResponse.IsCurrent
|
||||
- BoundCardInfo.IsCurrent
|
||||
affects:
|
||||
- Plan 03-02(依赖本 Plan 全部产出:模型字段 + Gateway 方法 + DTO 定义)
|
||||
tech_stack:
|
||||
added: []
|
||||
patterns:
|
||||
- golang-migrate 迁移文件(up/down 对)
|
||||
- GORM 模型字段追加(保持 gorm tag 格式一致性)
|
||||
- Gateway 泛型 doRequestWithResponse[T] 调用模式
|
||||
key_files:
|
||||
created:
|
||||
- migrations/000090_device_fields_extension.up.sql
|
||||
- migrations/000090_device_fields_extension.down.sql
|
||||
- migrations/000091_device_sim_binding_is_current.up.sql
|
||||
- migrations/000091_device_sim_binding_is_current.down.sql
|
||||
modified:
|
||||
- internal/model/device.go
|
||||
- internal/model/device_sim_binding.go
|
||||
- internal/gateway/models.go
|
||||
- internal/gateway/device.go
|
||||
- internal/model/dto/device_dto.go
|
||||
- internal/model/dto/asset_dto.go
|
||||
decisions:
|
||||
- "5 个 sync-info 字段有离线存储意义(设备下线后保留最后状态),非实时字段(rssi/battery)不入库"
|
||||
- "SyncDeviceInfo 使用同步 doRequestWithResponse[T] 泛型调用,与现有 GetDeviceInfo 区分(async vs sync)"
|
||||
- "is_current 字段位于 tb_device_sim_binding,由 sync-info current_iccid 决定"
|
||||
metrics:
|
||||
duration: "8min"
|
||||
completed_date: "2026-03-28"
|
||||
tasks: 2
|
||||
files: 10
|
||||
---
|
||||
|
||||
# Phase 03 Plan 01: 设备体系数据基础层 Summary
|
||||
|
||||
**一句话总结:** 新增 DB 迁移扩展 tb_device(5字段)和 tb_device_sim_binding(is_current),对接 Gateway sync-info 接口,并同步扩展 Device/DeviceSimBinding 模型及 DTO。
|
||||
|
||||
## Tasks Completed
|
||||
|
||||
| Task | Name | Commit | Files |
|
||||
|------|------|--------|-------|
|
||||
| 1 | DB 迁移 + 模型字段扩展(D-0 + D-2 DB 层) | `42b884a` | 4 迁移文件 + 2 模型文件 |
|
||||
| 2 | Gateway SyncDeviceInfo 方法 + DTO 字段扩展(D-1 + D-2 DTO 层) | `825def8` | gateway/models.go, gateway/device.go, device_dto.go, asset_dto.go |
|
||||
|
||||
## Artifacts Delivered
|
||||
|
||||
### 数据库迁移
|
||||
|
||||
- **000090_device_fields_extension**:tb_device 新增 `online_status`(INT DEFAULT 0)、`last_online_time`(TIMESTAMP NULL)、`software_version`(VARCHAR(100) DEFAULT '')、`switch_mode`(VARCHAR(10) DEFAULT '0')、`last_gateway_sync_at`(TIMESTAMP NULL)
|
||||
- **000091_device_sim_binding_is_current**:tb_device_sim_binding 新增 `is_current`(BOOLEAN DEFAULT FALSE)
|
||||
|
||||
### 模型更新
|
||||
|
||||
- **Device 模型**:追加 5 个字段(OnlineStatus / LastOnlineTime / SoftwareVersion / SwitchMode / LastGatewaySyncAt)
|
||||
- **DeviceSimBinding 模型**:追加 IsCurrent 字段
|
||||
|
||||
### Gateway 层
|
||||
|
||||
- **SyncDeviceInfoReq / SyncDeviceInfoResp**:18 字段的完整响应结构,支持 current_iccid / online_status / software_version / switch_mode / last_online_time 等关键字段
|
||||
- **SyncDeviceInfo() 方法**:POST /device/sync-info,同步返回全量数据(区别于异步 /device/info)
|
||||
|
||||
### DTO 扩展
|
||||
|
||||
- **DeviceResponse**:新增 5 个 sync-info 字段(与模型一一对应)
|
||||
- **DeviceCardBindingResponse**:新增 `IsCurrent bool`
|
||||
- **BoundCardInfo**:新增 `IsCurrent bool`
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
None — 计划完全按预期执行。
|
||||
|
||||
## Verification
|
||||
|
||||
- ✅ `make migrate-version` 输出版本 91,dirty=false
|
||||
- ✅ `go build ./...` 零新增编译错误
|
||||
- ✅ PostgreSQL MCP 验证 tb_device 含 5 个新列
|
||||
- ✅ PostgreSQL MCP 验证 tb_device_sim_binding 含 is_current
|
||||
- ✅ `SyncDeviceInfo` 方法在 internal/gateway/device.go 中实现
|
||||
|
||||
## Self-Check: PASSED
|
||||
Reference in New Issue
Block a user