All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 5m30s
主要变更: - 实现设备管理模块(创建、查询、列表、更新状态、删除) - 实现设备批量导入功能(CSV 解析、ICCID 绑定、异步任务处理) - 添加设备-SIM 卡绑定约束(部分唯一索引防止并发问题) - 修复 fee_rate 数据库字段类型(numeric -> bigint) - 修复测试数据隔离问题(基于增量断言) - 修复集成测试中间件顺序问题 - 清理无用测试文件(PersonalCustomer、Email 相关) - 归档 enterprise-card-authorization 变更
44 lines
2.5 KiB
Go
44 lines
2.5 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// DeviceImportTask 设备导入任务模型
|
|
// 记录设备批量导入的任务状态和处理结果
|
|
// 通过异步任务处理 CSV 文件导入设备并绑定卡
|
|
type DeviceImportTask struct {
|
|
gorm.Model
|
|
BaseModel `gorm:"embedded"`
|
|
TaskNo string `gorm:"column:task_no;type:varchar(50);uniqueIndex:idx_device_import_task_no,where:deleted_at IS NULL;not null;comment:任务编号(唯一)" json:"task_no"`
|
|
BatchNo string `gorm:"column:batch_no;type:varchar(100);comment:批次号" json:"batch_no"`
|
|
StorageKey string `gorm:"column:storage_key;type:varchar(500);comment:对象存储文件路径" json:"storage_key"`
|
|
FileName string `gorm:"column:file_name;type:varchar(255);comment:原始文件名" json:"file_name"`
|
|
Status int `gorm:"column:status;type:int;default:1;not null;comment:任务状态 1-待处理 2-处理中 3-已完成 4-失败" json:"status"`
|
|
TotalCount int `gorm:"column:total_count;type:int;default:0;comment:总记录数" json:"total_count"`
|
|
SuccessCount int `gorm:"column:success_count;type:int;default:0;comment:成功数" json:"success_count"`
|
|
SkipCount int `gorm:"column:skip_count;type:int;default:0;comment:跳过数" json:"skip_count"`
|
|
FailCount int `gorm:"column:fail_count;type:int;default:0;comment:失败数" json:"fail_count"`
|
|
SkippedItems ImportResultItems `gorm:"column:skipped_items;type:jsonb;comment:跳过记录详情" json:"skipped_items"`
|
|
FailedItems ImportResultItems `gorm:"column:failed_items;type:jsonb;comment:失败记录详情" json:"failed_items"`
|
|
WarningCount int `gorm:"column:warning_count;default:0;comment:警告数量(部分成功的设备)" json:"warning_count"`
|
|
WarningItems ImportResultItems `gorm:"column:warning_items;type:jsonb;comment:警告记录详情" json:"warning_items"`
|
|
ErrorMessage string `gorm:"column:error_message;type:text;comment:错误信息" json:"error_message"`
|
|
StartedAt *time.Time `gorm:"column:started_at;comment:开始处理时间" json:"started_at"`
|
|
CompletedAt *time.Time `gorm:"column:completed_at;comment:完成时间" json:"completed_at"`
|
|
}
|
|
|
|
// TableName 指定表名
|
|
func (DeviceImportTask) TableName() string {
|
|
return "tb_device_import_task"
|
|
}
|
|
|
|
// DeviceImportResultItem 设备导入结果项
|
|
type DeviceImportResultItem struct {
|
|
Line int `json:"line"`
|
|
DeviceNo string `json:"device_no"`
|
|
Reason string `json:"reason"`
|
|
}
|