package models import ( "time" "gorm.io/gorm" ) // Notification 通知模型 type Notification struct { ID int64 `json:"id" gorm:"type:bigint;primaryKey;autoIncrement;comment:通知ID"` UserID int64 `json:"user_id" gorm:"type:bigint;not null;index;comment:用户ID"` Type string `json:"type" gorm:"type:varchar(50);not null;index;comment:通知类型"` Title string `json:"title" gorm:"type:varchar(255);not null;comment:通知标题"` Content string `json:"content" gorm:"type:text;not null;comment:通知内容"` Link *string `json:"link" gorm:"type:varchar(500);comment:跳转链接"` IsRead bool `json:"is_read" gorm:"type:boolean;default:false;index;comment:是否已读"` Priority int `json:"priority" gorm:"type:tinyint;default:0;comment:优先级:0-普通,1-重要,2-紧急"` CreatedAt time.Time `json:"created_at" gorm:"type:timestamp;default:CURRENT_TIMESTAMP;index;comment:创建时间"` ReadAt *time.Time `json:"read_at" gorm:"type:timestamp;comment:阅读时间"` DeletedAt gorm.DeletedAt `json:"-" gorm:"index;comment:删除时间"` // 关联关系 User User `json:"-"` } // TableName 指定表名 func (Notification) TableName() string { return "ai_notifications" } // NotificationType 通知类型常量 const ( NotificationTypeSystem = "system" // 系统通知 NotificationTypeLearning = "learning" // 学习提醒 NotificationTypeAchievement = "achievement" // 成就通知 ) // NotificationPriority 通知优先级常量 const ( NotificationPriorityNormal = 0 // 普通 NotificationPriorityImportant = 1 // 重要 NotificationPriorityUrgent = 2 // 紧急 )