Files
huang 477a9fc98d
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled
feat: 添加设备IMEI和单卡ICCID查询接口
- 新增 GET /api/admin/devices/by-imei/:imei 接口,支持通过设备号查询设备详情
- 新增 GET /api/admin/iot-cards/by-iccid/:iccid 接口,支持通过ICCID查询单卡详情
- 添加对应的 Service 层方法和 Handler
- 更新 OpenAPI 文档
- 添加集成测试并修复测试环境配置(使用环境变量)
- 归档已完成的 OpenSpec 变更记录

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-27 09:59:54 +08:00

70 lines
3.1 KiB
Markdown
Raw Permalink 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 文档并验证