feat(profile): implement protected skin upload endpoint

This commit is contained in:
2025-06-16 07:20:09 +03:00
parent 9082b21a5d
commit 9c7940a70a
7 changed files with 186 additions and 9 deletions

View File

@@ -157,3 +157,22 @@ func (r *UserRepository) ValidateAccessToken(ctx context.Context, token string,
return nil
}
// UpdateSkinHash обновляет хеш скина для пользователя.
func (r *UserRepository) UpdateSkinHash(ctx context.Context, userID int, skinHash string) error {
query := "UPDATE profiles SET skin_hash = $1, updated_at = NOW() WHERE user_id = $2"
result, err := r.DB.ExecContext(ctx, query, skinHash, userID)
if err != nil {
return err
}
rowsAffected, err := result.RowsAffected()
if err != nil {
return err
}
if rowsAffected == 0 {
return ErrUserNotFound // Если профиль для user_id не найден
}
return nil
}