uint/uint64全部改为uint32
This commit is contained in:
@@ -2,8 +2,6 @@ package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// AlarmSourceType 定义了告警的来源类型
|
||||
@@ -46,13 +44,13 @@ const (
|
||||
)
|
||||
|
||||
// ActiveAlarm 活跃告警
|
||||
// 活跃告警会被更新(如忽略状态),因此保留 gorm.Model 以包含所有标准字段。
|
||||
// 活跃告警会被更新(如忽略状态),因此保留 Model 以包含所有标准字段。
|
||||
type ActiveAlarm struct {
|
||||
gorm.Model
|
||||
Model
|
||||
|
||||
SourceType AlarmSourceType `gorm:"type:varchar(50);not null;index:idx_alarm_uniqueness;comment:告警来源类型" json:"source_type"`
|
||||
// SourceID 告警来源ID,其具体含义取决于 SourceType 字段 (例如:设备ID, 区域主控ID, 猪栏ID)。
|
||||
SourceID uint `gorm:"not null;index:idx_alarm_uniqueness;comment:告警来源ID" json:"source_id"`
|
||||
SourceID uint32 `gorm:"not null;index:idx_alarm_uniqueness;comment:告警来源ID" json:"source_id"`
|
||||
|
||||
// AlarmCode 是一个机器可读的、标准化的告警类型标识。
|
||||
// 它与 SourceType 和 SourceID 共同构成一个活跃告警的唯一标识。
|
||||
@@ -79,15 +77,15 @@ func (ActiveAlarm) TableName() string {
|
||||
}
|
||||
|
||||
// HistoricalAlarm 历史告警
|
||||
// 历史告警是不可变归档数据,我们移除 gorm.Model,并手动定义字段。
|
||||
// 历史告警是不可变归档数据,我们移除 Model,并手动定义字段。
|
||||
// ID 和 TriggerTime 共同构成联合主键,以满足 TimescaleDB 超表的要求。
|
||||
type HistoricalAlarm struct {
|
||||
// 手动定义主键,ID 仍然自增
|
||||
ID uint `gorm:"primaryKey;autoIncrement;comment:主键ID" json:"id"`
|
||||
ID uint32 `gorm:"primaryKey;autoIncrement;comment:主键ID" json:"id"`
|
||||
|
||||
SourceType AlarmSourceType `gorm:"type:varchar(50);not null;index;comment:告警来源类型" json:"source_type"`
|
||||
// SourceID 告警来源ID,其具体含义取决于 SourceType 字段 (例如:设备ID, 区域主控ID, 猪栏ID)。
|
||||
SourceID uint `gorm:"not null;index;comment:告警来源ID" json:"source_id"`
|
||||
SourceID uint32 `gorm:"not null;index;comment:告警来源ID" json:"source_id"`
|
||||
|
||||
// AlarmCode 是一个机器可读的、标准化的告警类型标识。
|
||||
AlarmCode AlarmCode `gorm:"type:varchar(100);not null;index;comment:告警代码" json:"alarm_code"`
|
||||
@@ -99,8 +97,8 @@ type HistoricalAlarm struct {
|
||||
ResolveTime time.Time `gorm:"not null;comment:告警解决时间" json:"resolve_time"`
|
||||
ResolveMethod string `gorm:"comment:告警解决方式" json:"resolve_method"`
|
||||
|
||||
// ResolvedBy 使用指针类型 *uint 来表示可为空解决人, 当字段为空时表示系统自动解决的
|
||||
ResolvedBy *uint `gorm:"comment:告警解决人" json:"resolved_by"`
|
||||
// ResolvedBy 使用指针类型 *uint32 来表示可为空解决人, 当字段为空时表示系统自动解决的
|
||||
ResolvedBy *uint32 `gorm:"comment:告警解决人" json:"resolved_by"`
|
||||
}
|
||||
|
||||
// TableName 指定 HistoricalAlarm 结构体对应的数据库表名
|
||||
|
||||
Reference in New Issue
Block a user