2026-10-31 00:03:53 +08:00
|
|
|
|
// Package notification 存放 notifications 表的实体定义。
|
|
|
|
|
|
// worker 与 video 都依赖它,因此列标签只有一处。
|
2026-10-30 23:48:43 +08:00
|
|
|
|
package notification
|
|
|
|
|
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
|
|
|
|
|
|
|
type Notification struct {
|
|
|
|
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
|
|
|
|
RecipientID uint `gorm:"index;not null" json:"recipient_id"`
|
|
|
|
|
|
SenderID uint `gorm:"not null" json:"sender_id"`
|
|
|
|
|
|
Type string `gorm:"type:varchar(50);not null" json:"type"`
|
|
|
|
|
|
TargetID uint `gorm:"column:target_id" json:"target_id"`
|
|
|
|
|
|
Content string `gorm:"type:varchar(255)" json:"content"`
|
|
|
|
|
|
IsRead bool `gorm:"default:false" json:"is_read"`
|
|
|
|
|
|
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
|
|
|
|
|
|
2026-10-31 00:03:53 +08:00
|
|
|
|
// DedupeKey 用 *string:无意图键的通知写 NULL,不参与唯一约束。
|
2026-10-30 23:48:43 +08:00
|
|
|
|
DedupeKey *string `gorm:"column:dedupe_key;type:varchar(128);uniqueIndex:uk_notifications_dedupe" json:"-"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (Notification) TableName() string { return "notifications" }
|