feat:添加热榜功能并添加了增加热度的方法。

This commit is contained in:
Leon
2025-12-26 22:49:17 +08:00
parent 14a905e194
commit 328fae5f07
12 changed files with 327 additions and 10 deletions

View File

@@ -68,3 +68,12 @@ func (vr *VideoRepository) IsExist(ctx context.Context, id uint) (bool, error) {
}
return true, nil
}
func (vr *VideoRepository) UpdatePopularity(ctx context.Context, id uint, change int64) error {
if err := vr.db.WithContext(ctx).Model(&Video{}).
Where("id = ?", id).
Update("popularity", gorm.Expr("popularity + ?", change)).Error; err != nil {
return err
}
return nil
}