Files
logs/internal/models/resource_mapping.go
2026-04-27 19:26:57 +08:00

38 lines
1.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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"
}