// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.26.0
// source: user.sql

package user

import (
	"context"
)

const createSeller = `-- name: CreateSeller :one
INSERT INTO users (
    email, password, full_name, status
) VALUES (
    $1, $2, $3, $4
) RETURNING id
`

func (q *Queries) CreateSeller(ctx context.Context, email string, password string, fullName string, status UserStatus) (int64, error) {
	row := q.db.QueryRow(ctx, createSeller,
		email,
		password,
		fullName,
		status,
	)
	var id int64
	err := row.Scan(&id)
	return id, err
}

const createUser = `-- name: CreateUser :one
INSERT INTO users 
    (email, password, full_name)
VALUES 
    ($1, $2, $3)
RETURNING id, email, password, phone_number, full_name, status, created_at, updated_at
`

func (q *Queries) CreateUser(ctx context.Context, email string, password string, fullName string) (*User, error) {
	row := q.db.QueryRow(ctx, createUser, email, password, fullName)
	var i User
	err := row.Scan(
		&i.ID,
		&i.Email,
		&i.Password,
		&i.PhoneNumber,
		&i.FullName,
		&i.Status,
		&i.CreatedAt,
		&i.UpdatedAt,
	)
	return &i, err
}

const createUserWithPhone = `-- name: CreateUserWithPhone :one
INSERT INTO users
(email, password, full_name, phone_number)
VALUES
    ($1, $2, $3, $4)
RETURNING id, email, password, phone_number, full_name, status, created_at, updated_at
`

func (q *Queries) CreateUserWithPhone(ctx context.Context, email string, password string, fullName string, phoneNumber *string) (*User, error) {
	row := q.db.QueryRow(ctx, createUserWithPhone,
		email,
		password,
		fullName,
		phoneNumber,
	)
	var i User
	err := row.Scan(
		&i.ID,
		&i.Email,
		&i.Password,
		&i.PhoneNumber,
		&i.FullName,
		&i.Status,
		&i.CreatedAt,
		&i.UpdatedAt,
	)
	return &i, err
}

const createUserWithStatus = `-- name: CreateUserWithStatus :one
INSERT INTO users
    (email, password, full_name, status)
VALUES
    ($1, $2, $3, $4)
RETURNING id, email, password, phone_number, full_name, status, created_at, updated_at
`

func (q *Queries) CreateUserWithStatus(ctx context.Context, email string, password string, fullName string, status UserStatus) (*User, error) {
	row := q.db.QueryRow(ctx, createUserWithStatus,
		email,
		password,
		fullName,
		status,
	)
	var i User
	err := row.Scan(
		&i.ID,
		&i.Email,
		&i.Password,
		&i.PhoneNumber,
		&i.FullName,
		&i.Status,
		&i.CreatedAt,
		&i.UpdatedAt,
	)
	return &i, err
}

const createUserWithStatusAndPhone = `-- name: CreateUserWithStatusAndPhone :one
INSERT INTO users
(email, password, full_name, status, phone_number)
VALUES
    ($1, $2, $3, $4, $5)
RETURNING id, email, password, phone_number, full_name, status, created_at, updated_at
`

func (q *Queries) CreateUserWithStatusAndPhone(ctx context.Context, email string, password string, fullName string, status UserStatus, phoneNumber *string) (*User, error) {
	row := q.db.QueryRow(ctx, createUserWithStatusAndPhone,
		email,
		password,
		fullName,
		status,
		phoneNumber,
	)
	var i User
	err := row.Scan(
		&i.ID,
		&i.Email,
		&i.Password,
		&i.PhoneNumber,
		&i.FullName,
		&i.Status,
		&i.CreatedAt,
		&i.UpdatedAt,
	)
	return &i, err
}

const getUser = `-- name: GetUser :one
SELECT id, email, password, phone_number, full_name, status, created_at, updated_at FROM users WHERE id=$1
`

func (q *Queries) GetUser(ctx context.Context, id int64) (*User, error) {
	row := q.db.QueryRow(ctx, getUser, id)
	var i User
	err := row.Scan(
		&i.ID,
		&i.Email,
		&i.Password,
		&i.PhoneNumber,
		&i.FullName,
		&i.Status,
		&i.CreatedAt,
		&i.UpdatedAt,
	)
	return &i, err
}

const getUserByEmail = `-- name: GetUserByEmail :one
SELECT id, email, password, phone_number, full_name, status, created_at, updated_at FROM users WHERE email=$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.Email,
		&i.Password,
		&i.PhoneNumber,
		&i.FullName,
		&i.Status,
		&i.CreatedAt,
		&i.UpdatedAt,
	)
	return &i, err
}

const updateUserPassword = `-- name: UpdateUserPassword :exec
UPDATE users
SET password = $1
WHERE id = $2 AND status = 'Active'
`

func (q *Queries) UpdateUserPassword(ctx context.Context, password string, iD int64) error {
	_, err := q.db.Exec(ctx, updateUserPassword, password, iD)
	return err
}

const updateUserStatusByEmail = `-- name: UpdateUserStatusByEmail :exec
UPDATE users
SET status = $1
WHERE email = $2
`

func (q *Queries) UpdateUserStatusByEmail(ctx context.Context, status UserStatus, email string) error {
	_, err := q.db.Exec(ctx, updateUserStatusByEmail, status, email)
	return err
}
