117 lines
2.7 KiB
Go
117 lines
2.7 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: users.sql
|
|
|
|
package sqlc
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const createUser = `-- name: CreateUser :one
|
|
INSERT INTO users (id, user_name, user_mail, password) VALUES ($1, $2, $3, $4) RETURNING id
|
|
`
|
|
|
|
type CreateUserParams struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
UserName string `json:"user_name"`
|
|
UserMail string `json:"user_mail"`
|
|
Password string `json:"password"`
|
|
}
|
|
|
|
// users.sql
|
|
func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (pgtype.UUID, error) {
|
|
row := q.db.QueryRow(ctx, createUser,
|
|
arg.ID,
|
|
arg.UserName,
|
|
arg.UserMail,
|
|
arg.Password,
|
|
)
|
|
var id pgtype.UUID
|
|
err := row.Scan(&id)
|
|
return id, err
|
|
}
|
|
|
|
const getUserAuthByEmail = `-- name: GetUserAuthByEmail :one
|
|
SELECT id, user_name, user_mail, password
|
|
FROM users
|
|
WHERE user_mail = $1
|
|
`
|
|
|
|
type GetUserAuthByEmailRow struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
UserName string `json:"user_name"`
|
|
UserMail string `json:"user_mail"`
|
|
Password string `json:"password"`
|
|
}
|
|
|
|
func (q *Queries) GetUserAuthByEmail(ctx context.Context, userMail string) (GetUserAuthByEmailRow, error) {
|
|
row := q.db.QueryRow(ctx, getUserAuthByEmail, userMail)
|
|
var i GetUserAuthByEmailRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.UserName,
|
|
&i.UserMail,
|
|
&i.Password,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getUserByID = `-- name: GetUserByID :one
|
|
SELECT id, user_name, user_mail, created_at FROM users WHERE id = $1
|
|
`
|
|
|
|
type GetUserByIDRow struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
UserName string `json:"user_name"`
|
|
UserMail string `json:"user_mail"`
|
|
CreatedAt pgtype.Timestamp `json:"created_at"`
|
|
}
|
|
|
|
func (q *Queries) GetUserByID(ctx context.Context, id pgtype.UUID) (GetUserByIDRow, error) {
|
|
row := q.db.QueryRow(ctx, getUserByID, id)
|
|
var i GetUserByIDRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.UserName,
|
|
&i.UserMail,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getUsernameByID = `-- name: GetUsernameByID :one
|
|
SELECT user_name FROM users WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) GetUsernameByID(ctx context.Context, id pgtype.UUID) (string, error) {
|
|
row := q.db.QueryRow(ctx, getUsernameByID, id)
|
|
var user_name string
|
|
err := row.Scan(&user_name)
|
|
return user_name, err
|
|
}
|
|
|
|
const updateUser = `-- name: UpdateUser :exec
|
|
UPDATE users SET user_name = $2, user_mail = $3, password = $4 WHERE id = $1
|
|
`
|
|
|
|
type UpdateUserParams struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
UserName string `json:"user_name"`
|
|
UserMail string `json:"user_mail"`
|
|
Password string `json:"password"`
|
|
}
|
|
|
|
func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) error {
|
|
_, err := q.db.Exec(ctx, updateUser,
|
|
arg.ID,
|
|
arg.UserName,
|
|
arg.UserMail,
|
|
arg.Password,
|
|
)
|
|
return err
|
|
}
|