id type change

This commit is contained in:
nquidox 2026-03-06 19:07:33 +03:00
parent 520f0e6ec7
commit 11ff61f561
3 changed files with 7 additions and 7 deletions

View file

@ -3,5 +3,5 @@ package user
import "context"
type Provider interface {
GetUserId(ctx context.Context, userUuid string) (string, error)
GetUserId(ctx context.Context, userUuid string) (int64, error)
}

View file

@ -6,7 +6,7 @@ import (
)
type Repository interface {
getUserId(ctx context.Context, userUuid string) (string, error)
getUserId(ctx context.Context, userUuid string) (int64, error)
}
type repo struct {
@ -19,13 +19,13 @@ func newRepository(db *pgxpool.Pool) Repository {
}
}
func (r *repo) getUserId(ctx context.Context, userUuid string) (string, error) {
func (r *repo) getUserId(ctx context.Context, userUuid string) (int64, error) {
q := `SELECT id FROM users WHERE uuid = $1 AND deleted_at IS NULL LIMIT 1`
row := r.db.QueryRow(ctx, q, userUuid)
var id string
var id int64
if err := row.Scan(&id); err != nil {
return "", err
return 0, err
}
return id, nil

View file

@ -18,9 +18,9 @@ func newService(repo Repository, utils utils.Utils) *service {
}
}
func (s *service) GetUserId(ctx context.Context, userUuid string) (string, error) {
func (s *service) GetUserId(ctx context.Context, userUuid string) (int64, error) {
if userUuid == "" {
return "", errors.New("user uuid is empty")
return 0, errors.New("user uuid is empty")
}
return s.repo.getUserId(ctx, userUuid)