|
|
|
@@ -129,15 +129,17 @@ func (q *Queries) CreateEbookRating(ctx context.Context, arg CreateEbookRatingPa
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const CreateUser = `-- name: CreateUser :one
|
|
|
|
|
INSERT INTO users (email, username, password_hash, theme)
|
|
|
|
|
VALUES ($1, $2, $3, $4)
|
|
|
|
|
RETURNING id, email, username, theme, created_at, updated_at
|
|
|
|
|
INSERT INTO users (email, username, password_hash, first_name, last_name, theme)
|
|
|
|
|
VALUES ($1, $2, $3, $4, $5, $6)
|
|
|
|
|
RETURNING id, email, username, theme, first_name, last_name, created_at, updated_at
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
type CreateUserParams struct {
|
|
|
|
|
Email string `db:"email" json:"email"`
|
|
|
|
|
Username string `db:"username" json:"username"`
|
|
|
|
|
PasswordHash string `db:"password_hash" json:"password_hash"`
|
|
|
|
|
FirstName pgtype.Text `db:"first_name" json:"first_name"`
|
|
|
|
|
LastName pgtype.Text `db:"last_name" json:"last_name"`
|
|
|
|
|
Theme pgtype.Text `db:"theme" json:"theme"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -146,6 +148,8 @@ type CreateUserRow struct {
|
|
|
|
|
Email string `db:"email" json:"email"`
|
|
|
|
|
Username string `db:"username" json:"username"`
|
|
|
|
|
Theme pgtype.Text `db:"theme" json:"theme"`
|
|
|
|
|
FirstName pgtype.Text `db:"first_name" json:"first_name"`
|
|
|
|
|
LastName pgtype.Text `db:"last_name" json:"last_name"`
|
|
|
|
|
CreatedAt pgtype.Timestamptz `db:"created_at" json:"created_at"`
|
|
|
|
|
UpdatedAt pgtype.Timestamptz `db:"updated_at" json:"updated_at"`
|
|
|
|
|
}
|
|
|
|
@@ -155,6 +159,8 @@ func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (CreateU
|
|
|
|
|
arg.Email,
|
|
|
|
|
arg.Username,
|
|
|
|
|
arg.PasswordHash,
|
|
|
|
|
arg.FirstName,
|
|
|
|
|
arg.LastName,
|
|
|
|
|
arg.Theme,
|
|
|
|
|
)
|
|
|
|
|
var i CreateUserRow
|
|
|
|
@@ -163,6 +169,8 @@ func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (CreateU
|
|
|
|
|
&i.Email,
|
|
|
|
|
&i.Username,
|
|
|
|
|
&i.Theme,
|
|
|
|
|
&i.FirstName,
|
|
|
|
|
&i.LastName,
|
|
|
|
|
&i.CreatedAt,
|
|
|
|
|
&i.UpdatedAt,
|
|
|
|
|
)
|
|
|
|
@@ -398,7 +406,7 @@ func (q *Queries) GetScanSettings(ctx context.Context, id pgtype.UUID) (GetScanS
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const GetUser = `-- name: GetUser :one
|
|
|
|
|
SELECT id, email, username, theme, created_at, updated_at FROM users WHERE id = $1
|
|
|
|
|
SELECT id, email, username, theme, first_name, last_name, created_at, updated_at FROM users WHERE id = $1
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
type GetUserRow struct {
|
|
|
|
@@ -406,6 +414,8 @@ type GetUserRow struct {
|
|
|
|
|
Email string `db:"email" json:"email"`
|
|
|
|
|
Username string `db:"username" json:"username"`
|
|
|
|
|
Theme pgtype.Text `db:"theme" json:"theme"`
|
|
|
|
|
FirstName pgtype.Text `db:"first_name" json:"first_name"`
|
|
|
|
|
LastName pgtype.Text `db:"last_name" json:"last_name"`
|
|
|
|
|
CreatedAt pgtype.Timestamptz `db:"created_at" json:"created_at"`
|
|
|
|
|
UpdatedAt pgtype.Timestamptz `db:"updated_at" json:"updated_at"`
|
|
|
|
|
}
|
|
|
|
@@ -418,6 +428,8 @@ func (q *Queries) GetUser(ctx context.Context, id pgtype.UUID) (GetUserRow, erro
|
|
|
|
|
&i.Email,
|
|
|
|
|
&i.Username,
|
|
|
|
|
&i.Theme,
|
|
|
|
|
&i.FirstName,
|
|
|
|
|
&i.LastName,
|
|
|
|
|
&i.CreatedAt,
|
|
|
|
|
&i.UpdatedAt,
|
|
|
|
|
)
|
|
|
|
@@ -425,7 +437,7 @@ func (q *Queries) GetUser(ctx context.Context, id pgtype.UUID) (GetUserRow, erro
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const GetUserByEmail = `-- name: GetUserByEmail :one
|
|
|
|
|
SELECT id, email, username, theme, created_at, updated_at FROM users WHERE email = $1
|
|
|
|
|
SELECT id, email, username, theme, first_name, last_name, created_at, updated_at FROM users WHERE email = $1
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
type GetUserByEmailRow struct {
|
|
|
|
@@ -433,6 +445,8 @@ type GetUserByEmailRow struct {
|
|
|
|
|
Email string `db:"email" json:"email"`
|
|
|
|
|
Username string `db:"username" json:"username"`
|
|
|
|
|
Theme pgtype.Text `db:"theme" json:"theme"`
|
|
|
|
|
FirstName pgtype.Text `db:"first_name" json:"first_name"`
|
|
|
|
|
LastName pgtype.Text `db:"last_name" json:"last_name"`
|
|
|
|
|
CreatedAt pgtype.Timestamptz `db:"created_at" json:"created_at"`
|
|
|
|
|
UpdatedAt pgtype.Timestamptz `db:"updated_at" json:"updated_at"`
|
|
|
|
|
}
|
|
|
|
@@ -445,6 +459,8 @@ func (q *Queries) GetUserByEmail(ctx context.Context, email string) (GetUserByEm
|
|
|
|
|
&i.Email,
|
|
|
|
|
&i.Username,
|
|
|
|
|
&i.Theme,
|
|
|
|
|
&i.FirstName,
|
|
|
|
|
&i.LastName,
|
|
|
|
|
&i.CreatedAt,
|
|
|
|
|
&i.UpdatedAt,
|
|
|
|
|
)
|
|
|
|
@@ -452,7 +468,7 @@ func (q *Queries) GetUserByEmail(ctx context.Context, email string) (GetUserByEm
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const GetUserByEmailOrUsername = `-- name: GetUserByEmailOrUsername :one
|
|
|
|
|
SELECT id, email, username, theme, created_at, updated_at FROM users WHERE email = $1 OR username = $1
|
|
|
|
|
SELECT id, email, username, theme, first_name, last_name, created_at, updated_at FROM users WHERE email = $1 OR username = $1
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
type GetUserByEmailOrUsernameRow struct {
|
|
|
|
@@ -460,6 +476,8 @@ type GetUserByEmailOrUsernameRow struct {
|
|
|
|
|
Email string `db:"email" json:"email"`
|
|
|
|
|
Username string `db:"username" json:"username"`
|
|
|
|
|
Theme pgtype.Text `db:"theme" json:"theme"`
|
|
|
|
|
FirstName pgtype.Text `db:"first_name" json:"first_name"`
|
|
|
|
|
LastName pgtype.Text `db:"last_name" json:"last_name"`
|
|
|
|
|
CreatedAt pgtype.Timestamptz `db:"created_at" json:"created_at"`
|
|
|
|
|
UpdatedAt pgtype.Timestamptz `db:"updated_at" json:"updated_at"`
|
|
|
|
|
}
|
|
|
|
@@ -472,6 +490,8 @@ func (q *Queries) GetUserByEmailOrUsername(ctx context.Context, email string) (G
|
|
|
|
|
&i.Email,
|
|
|
|
|
&i.Username,
|
|
|
|
|
&i.Theme,
|
|
|
|
|
&i.FirstName,
|
|
|
|
|
&i.LastName,
|
|
|
|
|
&i.CreatedAt,
|
|
|
|
|
&i.UpdatedAt,
|
|
|
|
|
)
|
|
|
|
@@ -479,7 +499,7 @@ func (q *Queries) GetUserByEmailOrUsername(ctx context.Context, email string) (G
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const GetUserByUsername = `-- name: GetUserByUsername :one
|
|
|
|
|
SELECT id, email, username, theme, created_at, updated_at FROM users WHERE username = $1
|
|
|
|
|
SELECT id, email, username, theme, first_name, last_name, created_at, updated_at FROM users WHERE username = $1
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
type GetUserByUsernameRow struct {
|
|
|
|
@@ -487,6 +507,8 @@ type GetUserByUsernameRow struct {
|
|
|
|
|
Email string `db:"email" json:"email"`
|
|
|
|
|
Username string `db:"username" json:"username"`
|
|
|
|
|
Theme pgtype.Text `db:"theme" json:"theme"`
|
|
|
|
|
FirstName pgtype.Text `db:"first_name" json:"first_name"`
|
|
|
|
|
LastName pgtype.Text `db:"last_name" json:"last_name"`
|
|
|
|
|
CreatedAt pgtype.Timestamptz `db:"created_at" json:"created_at"`
|
|
|
|
|
UpdatedAt pgtype.Timestamptz `db:"updated_at" json:"updated_at"`
|
|
|
|
|
}
|
|
|
|
@@ -499,6 +521,8 @@ func (q *Queries) GetUserByUsername(ctx context.Context, username string) (GetUs
|
|
|
|
|
&i.Email,
|
|
|
|
|
&i.Username,
|
|
|
|
|
&i.Theme,
|
|
|
|
|
&i.FirstName,
|
|
|
|
|
&i.LastName,
|
|
|
|
|
&i.CreatedAt,
|
|
|
|
|
&i.UpdatedAt,
|
|
|
|
|
)
|
|
|
|
@@ -535,7 +559,7 @@ func (q *Queries) GetUserEbookFolders(ctx context.Context, userID pgtype.UUID) (
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const GetUserForLogin = `-- name: GetUserForLogin :one
|
|
|
|
|
SELECT id, email, username, password_hash, theme, created_at, updated_at FROM users WHERE email = $1 OR username = $1
|
|
|
|
|
SELECT id, email, username, password_hash, theme, first_name, last_name, created_at, updated_at FROM users WHERE email = $1 OR username = $1
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
type GetUserForLoginRow struct {
|
|
|
|
@@ -544,6 +568,8 @@ type GetUserForLoginRow struct {
|
|
|
|
|
Username string `db:"username" json:"username"`
|
|
|
|
|
PasswordHash string `db:"password_hash" json:"password_hash"`
|
|
|
|
|
Theme pgtype.Text `db:"theme" json:"theme"`
|
|
|
|
|
FirstName pgtype.Text `db:"first_name" json:"first_name"`
|
|
|
|
|
LastName pgtype.Text `db:"last_name" json:"last_name"`
|
|
|
|
|
CreatedAt pgtype.Timestamptz `db:"created_at" json:"created_at"`
|
|
|
|
|
UpdatedAt pgtype.Timestamptz `db:"updated_at" json:"updated_at"`
|
|
|
|
|
}
|
|
|
|
@@ -557,6 +583,8 @@ func (q *Queries) GetUserForLogin(ctx context.Context, email string) (GetUserFor
|
|
|
|
|
&i.Username,
|
|
|
|
|
&i.PasswordHash,
|
|
|
|
|
&i.Theme,
|
|
|
|
|
&i.FirstName,
|
|
|
|
|
&i.LastName,
|
|
|
|
|
&i.CreatedAt,
|
|
|
|
|
&i.UpdatedAt,
|
|
|
|
|
)
|
|
|
|
@@ -623,7 +651,7 @@ func (q *Queries) ListEbooks(ctx context.Context, arg ListEbooksParams) ([]Ebook
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ListUsers = `-- name: ListUsers :many
|
|
|
|
|
SELECT id, email, username, theme, created_at, updated_at FROM users ORDER BY created_at DESC
|
|
|
|
|
SELECT id, email, username, theme, first_name, last_name, created_at, updated_at FROM users ORDER BY created_at DESC
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
type ListUsersRow struct {
|
|
|
|
@@ -631,6 +659,8 @@ type ListUsersRow struct {
|
|
|
|
|
Email string `db:"email" json:"email"`
|
|
|
|
|
Username string `db:"username" json:"username"`
|
|
|
|
|
Theme pgtype.Text `db:"theme" json:"theme"`
|
|
|
|
|
FirstName pgtype.Text `db:"first_name" json:"first_name"`
|
|
|
|
|
LastName pgtype.Text `db:"last_name" json:"last_name"`
|
|
|
|
|
CreatedAt pgtype.Timestamptz `db:"created_at" json:"created_at"`
|
|
|
|
|
UpdatedAt pgtype.Timestamptz `db:"updated_at" json:"updated_at"`
|
|
|
|
|
}
|
|
|
|
@@ -649,6 +679,8 @@ func (q *Queries) ListUsers(ctx context.Context) ([]ListUsersRow, error) {
|
|
|
|
|
&i.Email,
|
|
|
|
|
&i.Username,
|
|
|
|
|
&i.Theme,
|
|
|
|
|
&i.FirstName,
|
|
|
|
|
&i.LastName,
|
|
|
|
|
&i.CreatedAt,
|
|
|
|
|
&i.UpdatedAt,
|
|
|
|
|
); err != nil {
|
|
|
|
@@ -845,6 +877,21 @@ func (q *Queries) UpdateScanSettings(ctx context.Context, arg UpdateScanSettings
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const UpdateUserProfile = `-- name: UpdateUserProfile :exec
|
|
|
|
|
UPDATE users SET first_name = $2, last_name = $3, updated_at = NOW() WHERE id = $1
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
type UpdateUserProfileParams struct {
|
|
|
|
|
ID pgtype.UUID `db:"id" json:"id"`
|
|
|
|
|
FirstName pgtype.Text `db:"first_name" json:"first_name"`
|
|
|
|
|
LastName pgtype.Text `db:"last_name" json:"last_name"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (q *Queries) UpdateUserProfile(ctx context.Context, arg UpdateUserProfileParams) error {
|
|
|
|
|
_, err := q.db.Exec(ctx, UpdateUserProfile, arg.ID, arg.FirstName, arg.LastName)
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const UpdateUserTheme = `-- name: UpdateUserTheme :exec
|
|
|
|
|
UPDATE users SET theme = $2, updated_at = NOW() WHERE id = $1
|
|
|
|
|
`
|
|
|
|
|