All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 4m45s
- 新增单卡分配/回收 API(支持 ICCID 列表、号段范围、筛选条件三种选卡方式) - 新增资产分配记录查询 API(支持多条件筛选和分页) - 新增 AssetAllocationRecord 模型、Store、Service、Handler 完整实现 - 扩展 IotCardStore 新增批量更新、号段查询、筛选查询等方法 - 修复 GORM Callback 处理 slice 类型(BatchCreate)的问题 - 新增完整的单元测试和集成测试 - 同步 OpenSpec 规范并归档 change
3.1 KiB
3.1 KiB
Tasks: 单卡资产分配功能
1. DTO 定义
- 1.1 创建 AllocateStandaloneCardsRequest DTO(支持三种选卡方式)
- 1.2 创建 AllocateStandaloneCardsResponse DTO(返回成功/失败统计)
- 1.3 创建 RecallStandaloneCardsRequest DTO
- 1.4 创建 RecallStandaloneCardsResponse DTO
- 1.5 创建 ListAssetAllocationRecordRequest DTO
- 1.6 创建 AssetAllocationRecordResponse DTO
- 1.7 创建 ListAssetAllocationRecordResponse DTO
2. Store 层
- 2.1 创建 AssetAllocationRecordStore
- 2.1.1 实现 Create 方法
- 2.1.2 实现 BatchCreate 方法
- 2.1.3 实现 GetByID 方法
- 2.1.4 实现 List 方法(支持筛选和分页)
- 2.2 实现 IotCardStore.BatchUpdateShopIDAndStatus 方法
- 2.3 实现 IotCardStore.GetStandaloneByICCIDRange 方法(号段查询)
- 2.4 实现 IotCardStore.GetStandaloneByFilters 方法(筛选条件查询,排除已绑定设备的卡)
- 2.5 实现 IotCardStore.GetByICCIDs 方法
- 2.6 实现 IotCardStore.GetBoundCardIDs 方法
3. Service 层
- 3.1 创建 AssetAllocationRecordService
- 3.1.1 实现 List 方法
- 3.1.2 实现 GetByID 方法
- 3.2 实现 IotCardService.AllocateCards 方法
- 3.2.1 校验目标店铺是当前用户的直属下级
- 3.2.2 根据选卡方式获取待分配的卡列表
- 3.2.3 校验卡是单卡(未绑定设备)
- 3.2.4 校验卡状态和所有权
- 3.2.5 批量更新 shop_id 和 status
- 3.2.6 创建分配记录
- 3.3 实现 IotCardService.RecallCards 方法
- 3.3.1 校验来源店铺是当前用户的直属下级
- 3.3.2 根据选卡方式获取待回收的卡列表
- 3.3.3 校验卡是单卡(未绑定设备)
- 3.3.4 批量更新 shop_id(平台→NULL,店铺→回收方ID)和 status
- 3.3.5 创建回收记录
4. Handler 层
- 4.1 创建 AssetAllocationRecordHandler
- 4.1.1 实现 List 方法
- 4.1.2 实现 GetByID 方法
- 4.2 实现 IotCardHandler.AllocateCards 方法
- 4.3 实现 IotCardHandler.RecallCards 方法
5. 路由注册
- 5.1 注册 POST /api/admin/iot-cards/standalone/allocate
- 5.2 注册 POST /api/admin/iot-cards/standalone/recall
- 5.3 注册 GET /api/admin/asset-allocation-records
- 5.4 注册 GET /api/admin/asset-allocation-records/:id
- 5.5 更新 Bootstrap(handlers.go、services.go、stores.go、types.go)
- 5.6 更新文档生成器(cmd/api/docs.go 和 cmd/gendocs/main.go)
6. 测试
- 6.1 AssetAllocationRecordStore 单元测试
- 6.2 IotCardStore.BatchUpdateShopIDAndStatus 单元测试
- 6.3 IotCardStore.GetStandaloneByICCIDRange 单元测试
- 6.4 IotCardStore.GetStandaloneByFilters 单元测试
- 6.5 IotCardStore.GetByICCIDs 单元测试
- 6.6 IotCardStore.GetBoundCardIDs 单元测试
- 6.7 分配 API 集成测试(TestStandaloneCardAllocation_AllocateByList)
- 6.8 回收 API 集成测试(TestStandaloneCardAllocation_Recall)
- 6.9 分配记录查询 API 集成测试(TestAssetAllocationRecord_List)
7. 文档更新
- 7.1 同步 delta spec 到主规范