38 lines
1.5 KiB
Go
38 lines
1.5 KiB
Go
|
|
package models
|
|||
|
|
|
|||
|
|
import "time"
|
|||
|
|
|
|||
|
|
// ResourceMapping 表示来自 dc-control 的资源映射快照。
|
|||
|
|
type ResourceMapping struct {
|
|||
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|||
|
|
// CreatedAt/UpdatedAt 由 GORM 维护。
|
|||
|
|
CreatedAt time.Time `json:"created_at"`
|
|||
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|||
|
|
|
|||
|
|
// ResourceType 资源类型(server/collector/device)。
|
|||
|
|
ResourceType string `gorm:"size:32;index:idx_logs_resource_unique,unique" json:"resource_type"`
|
|||
|
|
// ResourceID 资源 ID(来自 dc-control)。
|
|||
|
|
ResourceID string `gorm:"size:128;index:idx_logs_resource_unique,unique" json:"resource_id"`
|
|||
|
|
// ResourceName 资源名称。
|
|||
|
|
ResourceName string `gorm:"size:256" json:"resource_name"`
|
|||
|
|
|
|||
|
|
// IPsJSON/HostnamesJSON/LabelsJSON 以 JSON 文本存储数组和标签。
|
|||
|
|
IPsJSON string `gorm:"type:text" json:"ips_json"`
|
|||
|
|
HostnamesJSON string `gorm:"type:text" json:"hostnames_json"`
|
|||
|
|
LabelsJSON string `gorm:"type:text" json:"labels_json"`
|
|||
|
|
|
|||
|
|
// Version 用于处理乱序事件,仅允许新版本覆盖。
|
|||
|
|
Version int64 `gorm:"index" json:"version"`
|
|||
|
|
// IsDeleted 表示逻辑删除。
|
|||
|
|
IsDeleted bool `gorm:"index" json:"is_deleted"`
|
|||
|
|
// LastEventID 记录最后一次成功应用的事件 ID(幂等辅助)。
|
|||
|
|
LastEventID string `gorm:"size:128" json:"last_event_id"`
|
|||
|
|
// EventTime 记录事件产生时间。
|
|||
|
|
EventTime time.Time `json:"event_time"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
func (ResourceMapping) TableName() string {
|
|||
|
|
return "logs_resource_mappings"
|
|||
|
|
}
|
|||
|
|
|