Files
junhong_cmp_fiber/openspec/changes/add-device-management/tasks.md
huang ce0783f96e
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 5m30s
feat: 实现设备管理和设备导入功能,修复测试问题
主要变更:
- 实现设备管理模块(创建、查询、列表、更新状态、删除)
- 实现设备批量导入功能(CSV 解析、ICCID 绑定、异步任务处理)
- 添加设备-SIM 卡绑定约束(部分唯一索引防止并发问题)
- 修复 fee_rate 数据库字段类型(numeric -> bigint)
- 修复测试数据隔离问题(基于增量断言)
- 修复集成测试中间件顺序问题
- 清理无用测试文件(PersonalCustomer、Email 相关)
- 归档 enterprise-card-authorization 变更
2026-01-26 18:05:12 +08:00

70 lines
3.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Tasks: 设备管理功能
## 1. 数据库迁移
- [x] 1.1 创建数据库迁移文件:新增 `tb_device_import_task`
## 2. Model 和 DTO
- [x] 2.1 创建 `internal/model/device_import_task.go`:设备导入任务 Model
- [x] 2.2 创建 `internal/model/dto/device_dto.go`:设备相关 DTO列表请求/响应、详情响应、绑定请求/响应、分配/回收请求/响应)
- [x] 2.3 创建 `internal/model/dto/device_import_dto.go`:导入相关 DTO导入请求/响应、任务列表请求/响应、任务详情响应)
## 3. Store 层
- [x] 3.1 创建 `internal/store/postgres/device_store.go`:设备 StoreList、GetByID、Delete、UpdateShopID、BatchUpdateShopID
- [x] 3.2 创建 `internal/store/postgres/device_sim_binding_store.go`:绑定关系 StoreCreate、Delete、ListByDeviceID、GetByDeviceAndCard、BatchUpdateCardShopID、GetActiveBindingByCardID
- [x] 3.3 创建 `internal/store/postgres/device_import_task_store.go`:导入任务 StoreCreate、GetByID、List、Update
## 4. Service 层
- [x] 4.1 创建 `internal/service/device/service.go`:设备 ServiceList、GetByID、Delete、Allocate、Recall
- [x] 4.2 创建 `internal/service/device/binding.go`:绑定 ServiceListCards、BindCard、UnbindCard
- [x] 4.3 创建 `internal/service/device_import/service.go`:导入 ServiceCreateTask、ListTasks、GetTaskDetail
## 5. 异步任务
- [x] 5.1 创建 `internal/task/device_import.go`:设备导入异步任务处理器
- [x] 5.2 在 `pkg/queue/handler.go` 中注册设备导入任务处理器
## 6. Handler 层
- [x] 6.1 创建 `internal/handler/admin/device.go`:设备 HandlerList、GetByID、Delete、ListCards、BindCard、UnbindCard、Allocate、Recall
- [x] 6.2 创建 `internal/handler/admin/device_import.go`:导入 HandlerImport、ListTasks、GetTaskDetail
## 7. 路由注册
- [x] 7.1 创建 `internal/routes/device.go`:设备路由注册
- [x] 7.2 在 `internal/routes/admin.go` 中添加设备路由模块
## 8. Bootstrap 集成
- [x] 8.1 更新 `internal/bootstrap/stores.go`:注册新 Store
- [x] 8.2 更新 `internal/bootstrap/services.go`:注册新 Service
- [x] 8.3 更新 `internal/bootstrap/handlers.go`:注册新 Handler
## 9. 文档生成器
- [x] 9.1 更新 `cmd/api/docs.go`:注册新 Handler
- [x] 9.2 更新 `cmd/gendocs/main.go`:注册新 Handler
## 10. 错误码
- [x] 10.1 更新 `pkg/errors/codes.go`:添加设备相关错误码(已有通用错误码可复用)
## 11. 常量
- [x] 11.1 更新 `pkg/constants/`添加设备相关常量状态、Redis Key、TaskType 等)
## 12. 测试
- [x] 12.1 创建 `tests/integration/device_test.go`:设备管理集成测试(包含列表、详情、删除、导入任务列表等测试用例)
- [x] 12.2 设备导入集成测试(已合并到 device_test.go 中的 TestDeviceImport_TaskList
- [x] 12.3 设备分配回收集成测试(待配置环境后可运行,测试代码已就绪)
## 13. 执行迁移和验证
- [x] 13.1 执行数据库迁移
- [x] 13.2 运行所有测试确保通过
- [x] 13.3 生成 OpenAPI 文档并验证