Files
junhong_cmp_fiber/openspec/changes/add-card-device-series-bindng/tasks.md
huang 79c061b6fa
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 5m24s
feat: 实现套餐管理模块,包含套餐系列、双状态管理、废弃模型清理
- 新增套餐系列管理 (CRUD + 状态切换)
- 新增套餐管理 (CRUD + 启用/禁用 + 上架/下架双状态)
- 清理 8 个废弃分佣模型及对应数据库表
- Package 模型新增建议成本价、建议售价、上架状态字段
- 完整的 Store/Service/Handler 三层实现
- 包含单元测试和集成测试
- 归档 add-package-module change
- 新增多个 OpenSpec changes (订单支付、店铺套餐分配、一次性分佣、卡设备系列绑定)
2026-01-27 19:55:47 +08:00

3.3 KiB
Raw Blame History

1. IotCard 模型调整

  • 1.1 在 internal/model/iot_card.go 中新增 series_allocation_id 字段uint, index, 可空)
  • 1.2 新增 first_commission_paid 字段bool, 默认 false
  • 1.3 新增 accumulated_recharge 字段bigint, 默认 0

2. Device 模型调整

  • 2.1 在 internal/model/device.go 中新增 series_allocation_id 字段uint, index, 可空)
  • 2.2 新增 first_commission_paid 字段bool, 默认 false
  • 2.3 新增 accumulated_recharge 字段bigint, 默认 0

3. 数据库迁移

  • 3.1 创建迁移文件,为 tb_iot_card 添加 3 个新字段
  • 3.2 为 tb_device 添加 3 个新字段
  • 3.3 为 series_allocation_id 添加索引
  • 3.4 本地执行迁移验证

4. DTO 更新

  • 4.1 更新 IotCard 相关 DTO新增 series_allocation_id、first_commission_paid、accumulated_recharge 字段
  • 4.2 更新 Device 相关 DTO新增相同字段
  • 4.3 创建 BatchSetSeriesBindngRequesticcids/device_ids + series_allocation_id
  • 4.4 创建 BatchSetSeriesBindngResponse成功数、失败列表

5. IotCard Store 更新

  • 5.1 在 IotCardStore 中添加 BatchUpdateSeriesAllocation 方法
  • 5.2 添加 ListBySeriesAllocationID 方法(按系列筛选)
  • 5.3 更新 List 方法支持 series_allocation_id 筛选

6. Device Store 更新

  • 6.1 在 DeviceStore 中添加 BatchUpdateSeriesAllocation 方法
  • 6.2 添加 ListBySeriesAllocationID 方法
  • 6.3 更新 List 方法支持 series_allocation_id 筛选

7. IotCard Service 更新

  • 7.1 在 IotCardService 中添加 BatchSetSeriesBindng 方法(验证权限、验证系列分配)
  • 7.2 添加 ValidateSeriesAllocation 辅助方法(检查系列是否分配给店铺)

8. Device Service 更新

  • 8.1 在 DeviceService 中添加 BatchSetSeriesBindng 方法
  • 8.2 添加 ValidateSeriesAllocation 辅助方法

9. IotCard Handler 更新

  • 9.1 在 IotCardHandler 中添加 BatchSetSeriesBindng 接口PATCH /api/admin/iot-cards/series-bindng
  • 9.2 更新 List 接口支持 series_allocation_id 筛选参数
  • 9.3 更新 Get 接口响应包含系列关联信息

10. Device Handler 更新

  • 10.1 在 DeviceHandler 中添加 BatchSetSeriesBindng 接口PATCH /api/admin/devices/series-bindng
  • 10.2 更新 List 接口支持 series_allocation_id 筛选参数
  • 10.3 更新 Get 接口响应包含系列关联信息

11. 路由注册

  • 11.1 注册 PATCH /api/admin/iot-cards/series-bindng 路由
  • 11.2 注册 PATCH /api/admin/devices/series-bindng 路由

12. 文档生成器更新

  • 12.1 更新 docs.go 和 gendocs/main.go如有新 Handler
  • 12.2 执行文档生成验证

13. 测试

  • 13.1 IotCardStore 批量更新方法单元测试
  • 13.2 DeviceStore 批量更新方法单元测试
  • 13.3 IotCardService BatchSetSeriesBindng 单元测试(覆盖权限验证)
  • 13.4 DeviceService BatchSetSeriesBindng 单元测试
  • 13.5 卡系列关联 API 集成测试
  • 13.6 设备系列关联 API 集成测试
  • 13.7 执行 go test ./... 确认通过

14. 最终验证

  • 14.1 执行 go build ./... 确认编译通过
  • 14.2 启动服务,手动测试批量设置功能
  • 14.3 验证列表筛选功能正常