114 lines
2.4 KiB
Go
114 lines
2.4 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: users.sql
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const createUser = `-- name: CreateUser :one
|
|
INSERT INTO users (username, email, password_hash, full_name, created_by)
|
|
VALUES (
|
|
$1,
|
|
$2,
|
|
$3,
|
|
$4,
|
|
$5)
|
|
RETURNING id
|
|
`
|
|
|
|
type CreateUserParams struct {
|
|
Username string `db:"username" json:"username"`
|
|
Email string `db:"email" json:"email"`
|
|
PasswordHash string `db:"password_hash" json:"passwordHash"`
|
|
FullName pgtype.Text `db:"full_name" json:"fullName"`
|
|
CreatedBy pgtype.Text `db:"created_by" json:"createdBy"`
|
|
}
|
|
|
|
func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (uuid.UUID, error) {
|
|
row := q.db.QueryRow(ctx, createUser,
|
|
arg.Username,
|
|
arg.Email,
|
|
arg.PasswordHash,
|
|
arg.FullName,
|
|
arg.CreatedBy,
|
|
)
|
|
var id uuid.UUID
|
|
err := row.Scan(&id)
|
|
return id, err
|
|
}
|
|
|
|
const getUserByEmail = `-- name: GetUserByEmail :one
|
|
SELECT id, username, email, password_hash, full_name, is_active, created_at, updated_at, created_by FROM users
|
|
WHERE email = $1
|
|
LIMIT 1
|
|
`
|
|
|
|
func (q *Queries) GetUserByEmail(ctx context.Context, email string) (User, error) {
|
|
row := q.db.QueryRow(ctx, getUserByEmail, email)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Username,
|
|
&i.Email,
|
|
&i.PasswordHash,
|
|
&i.FullName,
|
|
&i.IsActive,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.CreatedBy,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getUserByID = `-- name: GetUserByID :one
|
|
SELECT id, username, email, password_hash, full_name, is_active, created_at, updated_at, created_by FROM users
|
|
WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) GetUserByID(ctx context.Context, id uuid.UUID) (User, error) {
|
|
row := q.db.QueryRow(ctx, getUserByID, id)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Username,
|
|
&i.Email,
|
|
&i.PasswordHash,
|
|
&i.FullName,
|
|
&i.IsActive,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.CreatedBy,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getUserByUsername = `-- name: GetUserByUsername :one
|
|
SELECT id, username, email, password_hash, full_name, is_active, created_at, updated_at, created_by FROM users
|
|
WHERE username = $1
|
|
LIMIT 1
|
|
`
|
|
|
|
func (q *Queries) GetUserByUsername(ctx context.Context, username string) (User, error) {
|
|
row := q.db.QueryRow(ctx, getUserByUsername, username)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Username,
|
|
&i.Email,
|
|
&i.PasswordHash,
|
|
&i.FullName,
|
|
&i.IsActive,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.CreatedBy,
|
|
)
|
|
return i, err
|
|
}
|