// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.28.0
// source: consignmentrejections.sql

package db

import (
	"context"
)

const createConsignmentRejection = `-- name: CreateConsignmentRejection :one
INSERT INTO consignmentrejections (
    cjcode,
    cjdescription
 ) VALUES (
    $1, $2
 ) RETURNING id, cjcode, cjdescription, created_at
`

type CreateConsignmentRejectionParams struct {
	Cjcode        string `json:"cjcode"`
	Cjdescription string `json:"cjdescription"`
}

func (q *Queries) CreateConsignmentRejection(ctx context.Context, arg CreateConsignmentRejectionParams) (Consignmentrejection, error) {
	row := q.db.QueryRowContext(ctx, createConsignmentRejection, arg.Cjcode, arg.Cjdescription)
	var i Consignmentrejection
	err := row.Scan(
		&i.ID,
		&i.Cjcode,
		&i.Cjdescription,
		&i.CreatedAt,
	)
	return i, err
}

const deleteConsignmentRejection = `-- name: DeleteConsignmentRejection :exec
DELETE FROM consignmentrejections WHERE id= $1
`

func (q *Queries) DeleteConsignmentRejection(ctx context.Context, id int64) error {
	_, err := q.db.ExecContext(ctx, deleteConsignmentRejection, id)
	return err
}

const getConsignmentRejection = `-- name: GetConsignmentRejection :one
SELECT id, cjcode, cjdescription, created_at FROM consignmentrejections
WHERE id = $1 LIMIT 1
`

func (q *Queries) GetConsignmentRejection(ctx context.Context, id int64) (Consignmentrejection, error) {
	row := q.db.QueryRowContext(ctx, getConsignmentRejection, id)
	var i Consignmentrejection
	err := row.Scan(
		&i.ID,
		&i.Cjcode,
		&i.Cjdescription,
		&i.CreatedAt,
	)
	return i, err
}

const listConsignmentRejections = `-- name: ListConsignmentRejections :many
SELECT id, cjcode, cjdescription, created_at FROM consignmentrejections
ORDER BY id LIMIT $1
OFFSET $2
`

type ListConsignmentRejectionsParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

func (q *Queries) ListConsignmentRejections(ctx context.Context, arg ListConsignmentRejectionsParams) ([]Consignmentrejection, error) {
	rows, err := q.db.QueryContext(ctx, listConsignmentRejections, arg.Limit, arg.Offset)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Consignmentrejection{}
	for rows.Next() {
		var i Consignmentrejection
		if err := rows.Scan(
			&i.ID,
			&i.Cjcode,
			&i.Cjdescription,
			&i.CreatedAt,
		); 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 updateConsignmentRejection = `-- name: UpdateConsignmentRejection :one
UPDATE consignmentrejections
  set 
    cjcode= $2,
    cjdescription= $3
WHERE id = $1
RETURNING id, cjcode, cjdescription, created_at
`

type UpdateConsignmentRejectionParams struct {
	ID            int64  `json:"id"`
	Cjcode        string `json:"cjcode"`
	Cjdescription string `json:"cjdescription"`
}

func (q *Queries) UpdateConsignmentRejection(ctx context.Context, arg UpdateConsignmentRejectionParams) (Consignmentrejection, error) {
	row := q.db.QueryRowContext(ctx, updateConsignmentRejection, arg.ID, arg.Cjcode, arg.Cjdescription)
	var i Consignmentrejection
	err := row.Scan(
		&i.ID,
		&i.Cjcode,
		&i.Cjdescription,
		&i.CreatedAt,
	)
	return i, err
}
