Files
junhong_cmp_fiber/openspec/changes/archive/2026-01-28-add-card-device-series-bindng/tasks.md
huang a945a4f554
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 5m37s
feat: 实现卡和设备的套餐系列绑定功能
- 添加 Device 和 IotCard 模型的 SeriesID 字段
- 实现 DeviceService 和 IotCardService 的套餐系列绑定逻辑
- 添加 DeviceStore 和 IotCardStore 的数据库操作方法
- 更新 API 接口和路由支持套餐系列绑定
- 创建数据库迁移脚本(000027_add_series_binding_fields)
- 添加完整的单元测试和集成测试
- 更新 OpenAPI 文档
- 归档 OpenSpec 变更文档

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-01-28 19:49:45 +08:00

86 lines
3.4 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.
## 1. IotCard 模型调整
- [x] 1.1 在 `internal/model/iot_card.go` 中新增 `series_allocation_id` 字段uint, index, 可空)
- [x] 1.2 新增 `first_commission_paid` 字段bool, 默认 false
- [x] 1.3 新增 `accumulated_recharge` 字段bigint, 默认 0
## 2. Device 模型调整
- [x] 2.1 在 `internal/model/device.go` 中新增 `series_allocation_id` 字段uint, index, 可空)
- [x] 2.2 新增 `first_commission_paid` 字段bool, 默认 false
- [x] 2.3 新增 `accumulated_recharge` 字段bigint, 默认 0
## 3. 数据库迁移
- [x] 3.1 创建迁移文件,为 tb_iot_card 添加 3 个新字段
- [x] 3.2 为 tb_device 添加 3 个新字段
- [x] 3.3 为 series_allocation_id 添加索引
- [~] 3.4 本地执行迁移验证 _(已取消:需要数据库连接)_
## 4. DTO 更新
- [x] 4.1 更新 IotCard 相关 DTO新增 series_allocation_id、first_commission_paid、accumulated_recharge 字段
- [x] 4.2 更新 Device 相关 DTO新增相同字段
- [x] 4.3 创建 BatchSetSeriesBindngRequesticcids/device_ids + series_allocation_id
- [x] 4.4 创建 BatchSetSeriesBindngResponse成功数、失败列表
## 5. IotCard Store 更新
- [x] 5.1 在 IotCardStore 中添加 BatchUpdateSeriesAllocation 方法
- [x] 5.2 添加 ListBySeriesAllocationID 方法(按系列筛选)
- [x] 5.3 更新 List 方法支持 series_allocation_id 筛选
## 6. Device Store 更新
- [x] 6.1 在 DeviceStore 中添加 BatchUpdateSeriesAllocation 方法
- [x] 6.2 添加 ListBySeriesAllocationID 方法
- [x] 6.3 更新 List 方法支持 series_allocation_id 筛选
## 7. IotCard Service 更新
- [x] 7.1 在 IotCardService 中添加 BatchSetSeriesBindng 方法(验证权限、验证系列分配)
- [x] 7.2 添加 ValidateSeriesAllocation 辅助方法(检查系列是否分配给店铺)
## 8. Device Service 更新
- [x] 8.1 在 DeviceService 中添加 BatchSetSeriesBindng 方法
- [x] 8.2 添加 ValidateSeriesAllocation 辅助方法
## 9. IotCard Handler 更新
- [x] 9.1 在 IotCardHandler 中添加 BatchSetSeriesBindng 接口PATCH /api/admin/iot-cards/series-bindng
- [x] 9.2 更新 List 接口支持 series_allocation_id 筛选参数
- [x] 9.3 更新 Get 接口响应包含系列关联信息
## 10. Device Handler 更新
- [x] 10.1 在 DeviceHandler 中添加 BatchSetSeriesBindng 接口PATCH /api/admin/devices/series-bindng
- [x] 10.2 更新 List 接口支持 series_allocation_id 筛选参数
- [x] 10.3 更新 Get 接口响应包含系列关联信息
## 11. 路由注册
- [x] 11.1 注册 `PATCH /api/admin/iot-cards/series-bindng` 路由
- [x] 11.2 注册 `PATCH /api/admin/devices/series-bindng` 路由
## 12. 文档生成器更新
- [x] 12.1 更新 docs.go 和 gendocs/main.go如有新 Handler
- [x] 12.2 执行文档生成验证
## 13. 测试
- [x] 13.1 IotCardStore 批量更新方法单元测试
- [x] 13.2 DeviceStore 批量更新方法单元测试
- [x] 13.3 IotCardService BatchSetSeriesBindng 单元测试(覆盖权限验证)
- [x] 13.4 DeviceService BatchSetSeriesBindng 单元测试
- [x] 13.5 卡系列关联 API 集成测试
- [x] 13.6 设备系列关联 API 集成测试
- [x] 13.7 执行 `go test ./...` 确认通过
## 14. 最终验证
- [x] 14.1 执行 `go build ./...` 确认编译通过
- [~] 14.2 启动服务,手动测试批量设置功能 _(已取消:需要运行服务)_
- [~] 14.3 验证列表筛选功能正常 _(已取消:单元测试已验证)_