// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.14.0
// source: users_gen.sql

package core_repo

import (
	"context"
)

const createUser = `-- name: CreateUser :one

INSERT INTO "public"."_users" (email,username,password,fullname) VALUES ($1, $2, $3, $4) RETURNING id, email, username, password, fullname, public, verified, blocked, role, updated, created
`

type CreateUserParams struct {
	Email    string `json:"email"`
	Username string `json:"username"`
	Password string `json:"password"`
	Fullname string `json:"fullname"`
}

// ------------------------------ ADD ONE _USERS <-> _USER  ------------------------------
func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error) {
	row := q.db.QueryRowContext(ctx, createUser,
		arg.Email,
		arg.Username,
		arg.Password,
		arg.Fullname,
	)
	var i User
	err := row.Scan(
		&i.ID,
		&i.Email,
		&i.Username,
		&i.Password,
		&i.Fullname,
		&i.Public,
		&i.Verified,
		&i.Blocked,
		&i.Role,
		&i.Updated,
		&i.Created,
	)
	return i, err
}

const deleteUser = `-- name: DeleteUser :exec

DELETE FROM "public"."_users" WHERE id = $1
`

// ------------------------------ REMOVE ONE _USERS -> nil  ------------------------------
func (q *Queries) DeleteUser(ctx context.Context, id int64) error {
	_, err := q.db.ExecContext(ctx, deleteUser, id)
	return err
}

const getAllUsers = `-- name: GetAllUsers :many

SELECT id, email, username, password, fullname, public, verified, blocked, role, updated, created FROM "public"."_users"
`

// ------------------------------ GET MULTIPLE _USERS <== [_USERS] ------------------------------
func (q *Queries) GetAllUsers(ctx context.Context) ([]User, error) {
	rows, err := q.db.QueryContext(ctx, getAllUsers)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []User{}
	for rows.Next() {
		var i User
		if err := rows.Scan(
			&i.ID,
			&i.Email,
			&i.Username,
			&i.Password,
			&i.Fullname,
			&i.Public,
			&i.Verified,
			&i.Blocked,
			&i.Role,
			&i.Updated,
			&i.Created,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Close(); err != nil {
		return nil, err
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const getSomeUsers = `-- name: GetSomeUsers :many
SELECT id, email, username, password, fullname, public, verified, blocked, role, updated, created FROM "public"."_users" LIMIT $2::int OFFSET $1::int
`

type GetSomeUsersParams struct {
	Offset int32 `json:"offset_"`
	Limit  int32 `json:"limit_"`
}

func (q *Queries) GetSomeUsers(ctx context.Context, arg GetSomeUsersParams) ([]User, error) {
	rows, err := q.db.QueryContext(ctx, getSomeUsers, arg.Offset, arg.Limit)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []User{}
	for rows.Next() {
		var i User
		if err := rows.Scan(
			&i.ID,
			&i.Email,
			&i.Username,
			&i.Password,
			&i.Fullname,
			&i.Public,
			&i.Verified,
			&i.Blocked,
			&i.Role,
			&i.Updated,
			&i.Created,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Close(); err != nil {
		return nil, err
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const getUser = `-- name: GetUser :one

SELECT id, email, username, password, fullname, public, verified, blocked, role, updated, created FROM "public"."_users" WHERE id = $1 LIMIT 1
`

// ------------------------------ GET ONE _USERS <== _USER  ------------------------------
func (q *Queries) GetUser(ctx context.Context, id int64) (User, error) {
	row := q.db.QueryRowContext(ctx, getUser, id)
	var i User
	err := row.Scan(
		&i.ID,
		&i.Email,
		&i.Username,
		&i.Password,
		&i.Fullname,
		&i.Public,
		&i.Verified,
		&i.Blocked,
		&i.Role,
		&i.Updated,
		&i.Created,
	)
	return i, err
}

const getUserWhereEmail = `-- name: GetUserWhereEmail :one
SELECT id, email, username, password, fullname, public, verified, blocked, role, updated, created FROM "public"."_users" WHERE email = $1 LIMIT 1
`

func (q *Queries) GetUserWhereEmail(ctx context.Context, email string) (User, error) {
	row := q.db.QueryRowContext(ctx, getUserWhereEmail, email)
	var i User
	err := row.Scan(
		&i.ID,
		&i.Email,
		&i.Username,
		&i.Password,
		&i.Fullname,
		&i.Public,
		&i.Verified,
		&i.Blocked,
		&i.Role,
		&i.Updated,
		&i.Created,
	)
	return i, err
}

const getUserWhereUsername = `-- name: GetUserWhereUsername :one
SELECT id, email, username, password, fullname, public, verified, blocked, role, updated, created FROM "public"."_users" WHERE username = $1 LIMIT 1
`

func (q *Queries) GetUserWhereUsername(ctx context.Context, username string) (User, error) {
	row := q.db.QueryRowContext(ctx, getUserWhereUsername, username)
	var i User
	err := row.Scan(
		&i.ID,
		&i.Email,
		&i.Username,
		&i.Password,
		&i.Fullname,
		&i.Public,
		&i.Verified,
		&i.Blocked,
		&i.Role,
		&i.Updated,
		&i.Created,
	)
	return i, err
}

const updateUserBlocked = `-- name: UpdateUserBlocked :one
UPDATE "public"."_users" SET blocked = $1 WHERE id = $2 RETURNING id, email, username, password, fullname, public, verified, blocked, role, updated, created
`

type UpdateUserBlockedParams struct {
	Blocked bool  `json:"blocked"`
	ID      int64 `json:"id"`
}

func (q *Queries) UpdateUserBlocked(ctx context.Context, arg UpdateUserBlockedParams) (User, error) {
	row := q.db.QueryRowContext(ctx, updateUserBlocked, arg.Blocked, arg.ID)
	var i User
	err := row.Scan(
		&i.ID,
		&i.Email,
		&i.Username,
		&i.Password,
		&i.Fullname,
		&i.Public,
		&i.Verified,
		&i.Blocked,
		&i.Role,
		&i.Updated,
		&i.Created,
	)
	return i, err
}

const updateUserFullName = `-- name: UpdateUserFullName :one

UPDATE "public"."_users" SET fullname = $1 WHERE id = $2 RETURNING id, email, username, password, fullname, public, verified, blocked, role, updated, created
`

type UpdateUserFullNameParams struct {
	Fullname string `json:"fullname"`
	ID       int64  `json:"id"`
}

// ------------------------------ UPDATE ONE _USERS <-> _USERS  ------------------------------
func (q *Queries) UpdateUserFullName(ctx context.Context, arg UpdateUserFullNameParams) (User, error) {
	row := q.db.QueryRowContext(ctx, updateUserFullName, arg.Fullname, arg.ID)
	var i User
	err := row.Scan(
		&i.ID,
		&i.Email,
		&i.Username,
		&i.Password,
		&i.Fullname,
		&i.Public,
		&i.Verified,
		&i.Blocked,
		&i.Role,
		&i.Updated,
		&i.Created,
	)
	return i, err
}

const updateUserPassword = `-- name: UpdateUserPassword :one
UPDATE "public"."_users" SET password = $1 WHERE id = $2 RETURNING id, email, username, password, fullname, public, verified, blocked, role, updated, created
`

type UpdateUserPasswordParams struct {
	Password string `json:"password"`
	ID       int64  `json:"id"`
}

func (q *Queries) UpdateUserPassword(ctx context.Context, arg UpdateUserPasswordParams) (User, error) {
	row := q.db.QueryRowContext(ctx, updateUserPassword, arg.Password, arg.ID)
	var i User
	err := row.Scan(
		&i.ID,
		&i.Email,
		&i.Username,
		&i.Password,
		&i.Fullname,
		&i.Public,
		&i.Verified,
		&i.Blocked,
		&i.Role,
		&i.Updated,
		&i.Created,
	)
	return i, err
}

const updateUserPublic = `-- name: UpdateUserPublic :one
UPDATE "public"."_users" SET public = $1 WHERE id = $2 RETURNING id, email, username, password, fullname, public, verified, blocked, role, updated, created
`

type UpdateUserPublicParams struct {
	Public bool  `json:"public"`
	ID     int64 `json:"id"`
}

func (q *Queries) UpdateUserPublic(ctx context.Context, arg UpdateUserPublicParams) (User, error) {
	row := q.db.QueryRowContext(ctx, updateUserPublic, arg.Public, arg.ID)
	var i User
	err := row.Scan(
		&i.ID,
		&i.Email,
		&i.Username,
		&i.Password,
		&i.Fullname,
		&i.Public,
		&i.Verified,
		&i.Blocked,
		&i.Role,
		&i.Updated,
		&i.Created,
	)
	return i, err
}

const updateUserUsername = `-- name: UpdateUserUsername :one
UPDATE "public"."_users" SET username = $1 WHERE id = $2 RETURNING id, email, username, password, fullname, public, verified, blocked, role, updated, created
`

type UpdateUserUsernameParams struct {
	Username string `json:"username"`
	ID       int64  `json:"id"`
}

func (q *Queries) UpdateUserUsername(ctx context.Context, arg UpdateUserUsernameParams) (User, error) {
	row := q.db.QueryRowContext(ctx, updateUserUsername, arg.Username, arg.ID)
	var i User
	err := row.Scan(
		&i.ID,
		&i.Email,
		&i.Username,
		&i.Password,
		&i.Fullname,
		&i.Public,
		&i.Verified,
		&i.Blocked,
		&i.Role,
		&i.Updated,
		&i.Created,
	)
	return i, err
}

const updateUserVerified = `-- name: UpdateUserVerified :one
UPDATE "public"."_users" SET verified = $1 WHERE id = $2 RETURNING id, email, username, password, fullname, public, verified, blocked, role, updated, created
`

type UpdateUserVerifiedParams struct {
	Verified bool  `json:"verified"`
	ID       int64 `json:"id"`
}

func (q *Queries) UpdateUserVerified(ctx context.Context, arg UpdateUserVerifiedParams) (User, error) {
	row := q.db.QueryRowContext(ctx, updateUserVerified, arg.Verified, arg.ID)
	var i User
	err := row.Scan(
		&i.ID,
		&i.Email,
		&i.Username,
		&i.Password,
		&i.Fullname,
		&i.Public,
		&i.Verified,
		&i.Blocked,
		&i.Role,
		&i.Updated,
		&i.Created,
	)
	return i, err
}
