fix
This commit is contained in:
@@ -27,9 +27,9 @@ func (r *UserRepository) CreateUser(ctx context.Context, user models.User) (*mod
|
||||
err := r.db.QueryRow(ctx, `
|
||||
INSERT INTO users (email, password_hash, first_name, second_name, birth_date, sex)
|
||||
VALUES ($1, $2, $3, $4, $5, $6)
|
||||
RETURNING id, created_at, updated_at
|
||||
RETURNING id, is_admin, created_at, updated_at
|
||||
`, user.Email, user.PasswordHash, user.FirstName, user.SecondName, user.BirthDate, user.Sex).
|
||||
Scan(&user.ID, &user.CreatedAt, &user.UpdatedAt)
|
||||
Scan(&user.ID, &user.IsAdmin, &user.CreatedAt, &user.UpdatedAt)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("create user: %w", err)
|
||||
}
|
||||
@@ -63,9 +63,15 @@ func (r *UserRepository) DeleteUser(ctx context.Context, id uuid.UUID) error {
|
||||
func (r *UserRepository) GetUserByEmail(ctx context.Context, email string) (*models.User, error) {
|
||||
var u models.User
|
||||
err := r.db.QueryRow(ctx, `
|
||||
SELECT id, email, password_hash, first_name, second_name, birth_date, sex, created_at, updated_at
|
||||
SELECT id, email, password_hash, first_name, second_name,
|
||||
birth_date, sex, is_admin, created_at, updated_at
|
||||
FROM users WHERE email = $1
|
||||
`, email).Scan(&u.ID, &u.Email, &u.PasswordHash, &u.FirstName, &u.SecondName, &u.BirthDate, &u.Sex, &u.CreatedAt, &u.UpdatedAt)
|
||||
`, email).Scan(
|
||||
&u.ID, &u.Email, &u.PasswordHash,
|
||||
&u.FirstName, &u.SecondName,
|
||||
&u.BirthDate, &u.Sex, &u.IsAdmin,
|
||||
&u.CreatedAt, &u.UpdatedAt,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -75,9 +81,15 @@ func (r *UserRepository) GetUserByEmail(ctx context.Context, email string) (*mod
|
||||
func (r *UserRepository) GetUserByID(ctx context.Context, id uuid.UUID) (*models.User, error) {
|
||||
var u models.User
|
||||
err := r.db.QueryRow(ctx, `
|
||||
SELECT id, email, password_hash, first_name, second_name, birth_date, sex, created_at, updated_at
|
||||
SELECT id, email, password_hash, first_name, second_name,
|
||||
birth_date, sex, is_admin, created_at, updated_at
|
||||
FROM users WHERE id = $1
|
||||
`, id).Scan(&u.ID, &u.Email, &u.PasswordHash, &u.FirstName, &u.SecondName, &u.BirthDate, &u.Sex, &u.CreatedAt, &u.UpdatedAt)
|
||||
`, id).Scan(
|
||||
&u.ID, &u.Email, &u.PasswordHash,
|
||||
&u.FirstName, &u.SecondName,
|
||||
&u.BirthDate, &u.Sex, &u.IsAdmin,
|
||||
&u.CreatedAt, &u.UpdatedAt,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user