feat: 实现运营商模块重构,添加冗余字段优化查询性能
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 5m16s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 5m16s
主要变更: - 新增 Carrier CRUD API(创建、列表、详情、更新、删除、状态更新) - IotCard/IotCardImportTask 添加 carrier_type/carrier_name 冗余字段 - 移除 Carrier 表的 channel_name/channel_code 字段 - 查询时直接使用冗余字段,避免 JOIN Carrier 表 - 添加数据库迁移脚本(000021-000023) - 添加单元测试和集成测试 - 同步更新 OpenAPI 文档和 specs
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
## Why
|
||||
|
||||
Carrier(运营商)模块目前只有 Model 定义,缺少管理接口。系统需要一套完整的 CRUD + 状态管理接口来创建和管理上游运营商渠道。同时,现有的 IotCard 等表通过 carrier_id 引用 Carrier,每次查询都需要 JOIN,且 Carrier 删除后历史数据会缺失。需要通过冗余字段实现"赋予时刻快照",让数据自包含。
|
||||
|
||||
## What Changes
|
||||
|
||||
- 新增 Carrier 管理 API(增删改查 + 启用/禁用)
|
||||
- 简化 Carrier Model,移除未使用的 `channel_name`、`channel_code` 字段
|
||||
- IotCard 新增冗余字段 `carrier_type`、`carrier_name`,导入时填充快照
|
||||
- IotCardImportTask 新增冗余字段 `carrier_name`(已有 `carrier_type`)
|
||||
- 优化查询逻辑,移除不必要的 JOIN 操作
|
||||
- **BREAKING**: 移除 Carrier 表的 `channel_name`、`channel_code` 字段及相关索引
|
||||
|
||||
## Capabilities
|
||||
|
||||
### New Capabilities
|
||||
|
||||
- `carrier-management`: 运营商管理功能,包含 CRUD 接口、状态管理、列表筛选
|
||||
|
||||
### Modified Capabilities
|
||||
|
||||
- `iot-card-import`: 导入时填充 carrier_type、carrier_name 冗余字段
|
||||
- `iot-card-query`: 查询响应直接使用冗余字段,无需 JOIN Carrier 表
|
||||
|
||||
## Impact
|
||||
|
||||
- **Model 层**: `carrier.go`(移除字段)、`iot_card.go`(新增字段)、`iot_card_import_task.go`(新增字段)
|
||||
- **新增文件**: `carrier_dto.go`、`carrier_store.go`、`carrier/service.go`、`carrier.go`(handler)、`carrier.go`(routes)
|
||||
- **修改文件**: `iot_card/service.go`、`iot_card_import/service.go`、`device/binding.go`(移除 JOIN 逻辑)
|
||||
- **Bootstrap**: 注册新的 Store、Service、Handler
|
||||
- **数据库**: 3 个迁移文件(Carrier 简化、IotCard 冗余、ImportTask 冗余)
|
||||
- **API**: 新增 `/api/admin/carriers` 路由组
|
||||
Reference in New Issue
Block a user