feat(P2): 粉丝/关注数 + 用户主页统计 (getProfile/getCounts)

This commit is contained in:
Sisyphus
2026-04-25 19:58:16 +08:00
parent 2322383036
commit ec56c73016
7 changed files with 227 additions and 127 deletions

View File

@@ -91,3 +91,19 @@ func (r *SocialRepository) IsFollowed(ctx context.Context, social *Social) (bool
}
return count > 0, nil
}
func (r *SocialRepository) CountFollowers(ctx context.Context, vloggerID uint) (int64, error) {
var count int64
if err := r.db.WithContext(ctx).Model(&Social{}).Where("vlogger_id = ?", vloggerID).Count(&count).Error; err != nil {
return 0, err
}
return count, nil
}
func (r *SocialRepository) CountVloggers(ctx context.Context, followerID uint) (int64, error) {
var count int64
if err := r.db.WithContext(ctx).Model(&Social{}).Where("follower_id = ?", followerID).Count(&count).Error; err != nil {
return 0, err
}
return count, nil
}