package models import ( "time" ) // NotificationType represents the type of notification type NotificationType string const ( NotificationTypeSystem NotificationType = "system" NotificationTypeAlert NotificationType = "alert" NotificationTypeInfo NotificationType = "info" ) // Notification represents a system notification for a user type Notification struct { BaseModel UserID uint `gorm:"not null;index" json:"user_id"` Title string `gorm:"size:200;not null" json:"title"` Content string `gorm:"type:text;not null" json:"content"` Type NotificationType `gorm:"size:20;not null;default:'system'" json:"type"` IsRead bool `gorm:"default:false" json:"is_read"` Link string `gorm:"size:255" json:"link,omitempty"` // Optional link to redirect ReadAt *time.Time `json:"read_at,omitempty"` // Relationships User User `gorm:"foreignKey:UserID" json:"-"` } // TableName specifies the table name for Notification func (Notification) TableName() string { return "notifications" }