fix: Social GetAllFollowers/Vloggers + Like ListLikedVideos 加 Limit(200) 防海量数据

This commit is contained in:
Sisyphus
2026-04-25 17:45:33 +08:00
parent 48a7eea0f9
commit 1cadc95863
2 changed files with 195 additions and 192 deletions

View File

@@ -30,6 +30,7 @@ func (r *SocialRepository) GetAllFollowers(ctx context.Context, VloggerID uint)
if err := r.db.WithContext(ctx). if err := r.db.WithContext(ctx).
Model(&Social{}). Model(&Social{}).
Where("vlogger_id = ?", VloggerID). Where("vlogger_id = ?", VloggerID).
Limit(200).
Find(&relations).Error; err != nil { Find(&relations).Error; err != nil {
return nil, err return nil, err
} }
@@ -57,6 +58,7 @@ func (r *SocialRepository) GetAllVloggers(ctx context.Context, FollowerID uint)
if err := r.db.WithContext(ctx). if err := r.db.WithContext(ctx).
Model(&Social{}). Model(&Social{}).
Where("follower_id = ?", FollowerID). Where("follower_id = ?", FollowerID).
Limit(200).
Find(&relations).Error; err != nil { Find(&relations).Error; err != nil {
return nil, err return nil, err
} }

View File

@@ -93,6 +93,7 @@ func (r *LikeRepository) ListLikedVideos(ctx context.Context, accountID uint) ([
Joins("JOIN likes ON likes.video_id = videos.id"). Joins("JOIN likes ON likes.video_id = videos.id").
Where("likes.account_id = ?", accountID). Where("likes.account_id = ?", accountID).
Order("likes.created_at desc"). Order("likes.created_at desc").
Limit(200).
Find(&videos).Error Find(&videos).Error
if err != nil { if err != nil {
return nil, err return nil, err