package video import "time" // Like 的两个索引都承载语义,不能删: // - idx_like_video_account(video_id, account_id,唯一)是 ApplyLike 的判重门闩: // RowsAffected==0 表示这条互动已经存在,计数与热榜都不得再加。 // - idx_likes_created_video(created_at, video_id)让热榜窗口查询只走索引, // 不回表。created_at 是事件时间,撤销点赞要减回同一分钟。 type Like struct { ID uint `gorm:"primaryKey" json:"id"` VideoID uint `gorm:"uniqueIndex:idx_like_video_account;index:idx_likes_created_video,priority:2;not null" json:"video_id"` AccountID uint `gorm:"uniqueIndex:idx_like_video_account;not null" json:"account_id"` CreatedAt time.Time `gorm:"index:idx_likes_created_video,priority:1" json:"created_at"` } type LikeRequest struct { VideoID uint `json:"video_id"` }