package model import ( "time" ) // CustomDashboard 自定义监控仪表盘(面板配置存 JSON) // Logan.Li type CustomDashboard struct { ID uint `gorm:"primaryKey;autoIncrement;comment:主键ID" json:"id"` Name string `gorm:"type:varchar(128);not null;comment:仪表盘名称" json:"name"` Description string `gorm:"type:varchar(512);comment:描述" json:"description"` Datasource string `gorm:"type:varchar(32);default:'prometheus';comment:数据源类型" json:"datasource"` DatasourceURL string `gorm:"type:varchar(512);comment:数据源URL(留空则用默认Prometheus)" json:"datasource_url"` // Panels 存储面板配置 JSON 数组: [{id,title,type,query,width,height,x,y,options}] Panels string `gorm:"type:longtext;comment:面板配置JSON" json:"panels"` // Tags 标签(JSON 数组字符串) Tags string `gorm:"type:varchar(512);comment:标签JSON" json:"tags,omitempty"` // 归属 CreatedBy string `gorm:"type:varchar(64);comment:创建人" json:"created_by"` IsDefault bool `gorm:"default:false;index;comment:是否默认仪表盘" json:"is_default"` IsFavorite bool `gorm:"default:false;comment:是否收藏" json:"is_favorite"` // 时间戳 CreatedAt time.Time `gorm:"not null;index;comment:创建时间" json:"created_at"` UpdatedAt time.Time `gorm:"not null;comment:更新时间" json:"updated_at"` DeletedAt *time.Time `gorm:"index;comment:删除时间" json:"deleted_at,omitempty"` } // TableName 指定表名 func (CustomDashboard) TableName() string { return "monitor_custom_dashboards" }