refactor:优化了like和unlike功能

This commit is contained in:
Leon
2025-12-23 02:20:08 +08:00
parent de732abeb1
commit b0a7c85a8d
3 changed files with 38 additions and 84 deletions

View File

@@ -34,14 +34,3 @@ func (r *LikeRepository) IsLiked(ctx context.Context, videoID, accountID uint) (
}
return count > 0, nil
}
func (r *LikeRepository) GetLikesCount(ctx context.Context, videoID uint) (int64, error) {
var count int64
err := r.db.WithContext(ctx).Model(&Like{}).
Where("video_id = ?", videoID).
Count(&count).Error
if err != nil {
return 0, err
}
return count, nil
}