feat: 0.0.1
This commit is contained in:
146 files changed
+10444
No files matched your search
@@ -0,0 +1,117 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.30.0
|
||||
// source: user.sql
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const createUser = `-- name: CreateUser :one
|
||||
INSERT INTO users (
|
||||
username,
|
||||
hashed_password,
|
||||
full_name,
|
||||
email
|
||||
) VALUES (
|
||||
$1, $2, $3, $4
|
||||
)
|
||||
RETURNING username, role, hashed_password, full_name, email, is_email_verified, password_changed_at, created_at
|
||||
`
|
||||
|
||||
type CreateUserParams struct {
|
||||
Username string `json:"username"`
|
||||
HashedPassword string `json:"hashed_password"`
|
||||
FullName string `json:"full_name"`
|
||||
Email string `json:"email"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error) {
|
||||
row := q.db.QueryRow(ctx, createUser,
|
||||
arg.Username,
|
||||
arg.HashedPassword,
|
||||
arg.FullName,
|
||||
arg.Email,
|
||||
)
|
||||
var i User
|
||||
err := row.Scan(
|
||||
&i.Username,
|
||||
&i.Role,
|
||||
&i.HashedPassword,
|
||||
&i.FullName,
|
||||
&i.Email,
|
||||
&i.IsEmailVerified,
|
||||
&i.PasswordChangedAt,
|
||||
&i.CreatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getUser = `-- name: GetUser :one
|
||||
SELECT username, role, hashed_password, full_name, email, is_email_verified, password_changed_at, created_at FROM users
|
||||
WHERE username = $1 LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetUser(ctx context.Context, username string) (User, error) {
|
||||
row := q.db.QueryRow(ctx, getUser, username)
|
||||
var i User
|
||||
err := row.Scan(
|
||||
&i.Username,
|
||||
&i.Role,
|
||||
&i.HashedPassword,
|
||||
&i.FullName,
|
||||
&i.Email,
|
||||
&i.IsEmailVerified,
|
||||
&i.PasswordChangedAt,
|
||||
&i.CreatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateUser = `-- name: UpdateUser :one
|
||||
UPDATE users
|
||||
SET
|
||||
hashed_password = COALESCE($1, hashed_password),
|
||||
password_changed_at = COALESCE($2, password_changed_at),
|
||||
full_name = COALESCE($3, full_name),
|
||||
email = COALESCE($4, email),
|
||||
is_email_verified = COALESCE($5, is_email_verified)
|
||||
WHERE username = $6
|
||||
RETURNING username, role, hashed_password, full_name, email, is_email_verified, password_changed_at, created_at
|
||||
`
|
||||
|
||||
type UpdateUserParams struct {
|
||||
HashedPassword pgtype.Text `json:"hashed_password"`
|
||||
PasswordChangedAt pgtype.Timestamptz `json:"password_changed_at"`
|
||||
FullName pgtype.Text `json:"full_name"`
|
||||
Email pgtype.Text `json:"email"`
|
||||
IsEmailVerified pgtype.Bool `json:"is_email_verified"`
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) (User, error) {
|
||||
row := q.db.QueryRow(ctx, updateUser,
|
||||
arg.HashedPassword,
|
||||
arg.PasswordChangedAt,
|
||||
arg.FullName,
|
||||
arg.Email,
|
||||
arg.IsEmailVerified,
|
||||
arg.Username,
|
||||
)
|
||||
var i User
|
||||
err := row.Scan(
|
||||
&i.Username,
|
||||
&i.Role,
|
||||
&i.HashedPassword,
|
||||
&i.FullName,
|
||||
&i.Email,
|
||||
&i.IsEmailVerified,
|
||||
&i.PasswordChangedAt,
|
||||
&i.CreatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
Reference in new issue
Block a user