All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m35s
- 新增不轮询清单 tb_card_polling_pause(迁移 000256 补写存量),所有改 enable_polling 的入口同事务写清单 - 卡、设备勾选批量开关轮询(单次 500,逐项结果,开启跳过风险停机与已销户)与 CSV 文件导入 - 订单套餐生效、改有效期后自动恢复轮询并按规则评估复机 - 不轮询清单查询与导出;卡、设备列表与导出增加是否轮询 - 失败告警停机被拒视图、导出与批量关闭轮询;开关轮询影响说明 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
97 lines
5.1 KiB
Go
97 lines
5.1 KiB
Go
package model
|
|
|
|
import (
|
|
"database/sql/driver"
|
|
"time"
|
|
|
|
"github.com/bytedance/sonic"
|
|
)
|
|
|
|
// CardPollingPause 不轮询清单记录:同一资产只有一条已关闭记录,恢复后保留历史。调度不读本表。
|
|
type CardPollingPause struct {
|
|
ID uint `gorm:"column:id;primaryKey" json:"id"`
|
|
AssetType string `gorm:"column:asset_type;type:varchar(20);not null" json:"asset_type"`
|
|
AssetID uint `gorm:"column:asset_id;not null" json:"asset_id"`
|
|
Identifier string `gorm:"column:identifier;type:varchar(100);not null;default:''" json:"identifier"`
|
|
CarrierID uint `gorm:"column:carrier_id;not null;default:0" json:"carrier_id"`
|
|
Status int `gorm:"column:status;type:smallint;not null;default:1" json:"status"`
|
|
CloseSource string `gorm:"column:close_source;type:varchar(30);not null" json:"close_source"`
|
|
CloseReason string `gorm:"column:close_reason;type:varchar(500);not null;default:''" json:"close_reason"`
|
|
ClosedBy uint `gorm:"column:closed_by;not null;default:0" json:"closed_by"`
|
|
ClosedAt time.Time `gorm:"column:closed_at;not null" json:"closed_at"`
|
|
ImportTaskID uint `gorm:"column:import_task_id;not null;default:0" json:"import_task_id"`
|
|
RestoreSource string `gorm:"column:restore_source;type:varchar(30);not null;default:''" json:"restore_source"`
|
|
RestoreReason string `gorm:"column:restore_reason;type:varchar(500);not null;default:''" json:"restore_reason"`
|
|
RestoredBy uint `gorm:"column:restored_by;not null;default:0" json:"restored_by"`
|
|
RestoredAt *time.Time `gorm:"column:restored_at" json:"restored_at"`
|
|
CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
|
|
UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at"`
|
|
}
|
|
|
|
// TableName 返回不轮询清单表名。
|
|
func (CardPollingPause) TableName() string {
|
|
return "tb_card_polling_pause"
|
|
}
|
|
|
|
// PollingStatusImportTask 轮询开关文件导入任务。
|
|
type PollingStatusImportTask struct {
|
|
ID uint `gorm:"column:id;primaryKey" json:"id"`
|
|
TaskNo string `gorm:"column:task_no;type:varchar(50);not null" json:"task_no"`
|
|
AssetType string `gorm:"column:asset_type;type:varchar(20);not null" json:"asset_type"`
|
|
EnablePolling bool `gorm:"column:enable_polling;not null" json:"enable_polling"`
|
|
Reason string `gorm:"column:reason;type:varchar(500);not null;default:''" json:"reason"`
|
|
FileName string `gorm:"column:file_name;type:varchar(255);not null;default:''" json:"file_name"`
|
|
StorageKey string `gorm:"column:storage_key;type:varchar(500);not null" json:"storage_key"`
|
|
Status int `gorm:"column:status;not null;default:1" json:"status"`
|
|
TotalCount int `gorm:"column:total_count;not null;default:0" json:"total_count"`
|
|
SuccessCount int `gorm:"column:success_count;not null;default:0" json:"success_count"`
|
|
SkipCount int `gorm:"column:skip_count;not null;default:0" json:"skip_count"`
|
|
FailCount int `gorm:"column:fail_count;not null;default:0" json:"fail_count"`
|
|
ResultItems PollingStatusImportResults `gorm:"column:result_items;type:jsonb;not null;default:'[]'" json:"result_items"`
|
|
ErrorMessage string `gorm:"column:error_message;type:text;not null;default:''" json:"error_message"`
|
|
Creator uint `gorm:"column:creator;not null;default:0" json:"creator"`
|
|
CreatorName string `gorm:"column:creator_name;type:varchar(100);not null;default:''" json:"creator_name"`
|
|
StartedAt *time.Time `gorm:"column:started_at" json:"started_at"`
|
|
CompletedAt *time.Time `gorm:"column:completed_at" json:"completed_at"`
|
|
CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
|
|
UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at"`
|
|
}
|
|
|
|
// TableName 返回轮询开关导入任务表名。
|
|
func (PollingStatusImportTask) TableName() string {
|
|
return "tb_polling_status_import_task"
|
|
}
|
|
|
|
// PollingStatusImportResultItem 导入单行结果;行号自数据首行起计。
|
|
type PollingStatusImportResultItem struct {
|
|
Line int `json:"line"`
|
|
Identifier string `json:"identifier"`
|
|
AssetID uint `json:"asset_id,omitempty"`
|
|
Status int `json:"status"`
|
|
Reason string `json:"reason,omitempty"`
|
|
}
|
|
|
|
// PollingStatusImportResults 导入逐行结果集合。
|
|
type PollingStatusImportResults []PollingStatusImportResultItem
|
|
|
|
// Value 将逐行结果序列化为 JSONB。
|
|
func (items PollingStatusImportResults) Value() (driver.Value, error) {
|
|
if items == nil {
|
|
return "[]", nil
|
|
}
|
|
return sonic.Marshal(items)
|
|
}
|
|
|
|
// Scan 从 JSONB 读取逐行结果。
|
|
func (items *PollingStatusImportResults) Scan(value any) error {
|
|
if value == nil {
|
|
*items = PollingStatusImportResults{}
|
|
return nil
|
|
}
|
|
data, ok := value.([]byte)
|
|
if !ok {
|
|
return nil
|
|
}
|
|
return sonic.Unmarshal(data, items)
|
|
}
|