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