id type change
This commit is contained in:
parent
520f0e6ec7
commit
11ff61f561
3 changed files with 7 additions and 7 deletions
|
|
@ -3,5 +3,5 @@ package user
|
||||||
import "context"
|
import "context"
|
||||||
|
|
||||||
type Provider interface {
|
type Provider interface {
|
||||||
GetUserId(ctx context.Context, userUuid string) (string, error)
|
GetUserId(ctx context.Context, userUuid string) (int64, error)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Repository interface {
|
type Repository interface {
|
||||||
getUserId(ctx context.Context, userUuid string) (string, error)
|
getUserId(ctx context.Context, userUuid string) (int64, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type repo struct {
|
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`
|
q := `SELECT id FROM users WHERE uuid = $1 AND deleted_at IS NULL LIMIT 1`
|
||||||
row := r.db.QueryRow(ctx, q, userUuid)
|
row := r.db.QueryRow(ctx, q, userUuid)
|
||||||
|
|
||||||
var id string
|
var id int64
|
||||||
if err := row.Scan(&id); err != nil {
|
if err := row.Scan(&id); err != nil {
|
||||||
return "", err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return id, nil
|
return id, nil
|
||||||
|
|
|
||||||
|
|
@ -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 == "" {
|
if userUuid == "" {
|
||||||
return "", errors.New("user uuid is empty")
|
return 0, errors.New("user uuid is empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.repo.getUserId(ctx, userUuid)
|
return s.repo.getUserId(ctx, userUuid)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue