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

package db

import (
	"context"
)

const createReceptionFormQRCode = `-- name: CreateReceptionFormQRCode :one
INSERT INTO receptionform_qrcodes (
    receptionform_id,            
    qrcode
 ) VALUES (
     $1, 
     $2
    ) 
RETURNING id, receptionform_id, qrcode, created_at
`

type CreateReceptionFormQRCodeParams struct {
	ReceptionformID int32  `json:"receptionform_id"`
	Qrcode          string `json:"qrcode"`
}

func (q *Queries) CreateReceptionFormQRCode(ctx context.Context, arg CreateReceptionFormQRCodeParams) (ReceptionformQrcode, error) {
	row := q.db.QueryRowContext(ctx, createReceptionFormQRCode, arg.ReceptionformID, arg.Qrcode)
	var i ReceptionformQrcode
	err := row.Scan(
		&i.ID,
		&i.ReceptionformID,
		&i.Qrcode,
		&i.CreatedAt,
	)
	return i, err
}

const deleteReceptionFormQRcodes = `-- name: DeleteReceptionFormQRcodes :exec
DELETE FROM receptionform_qrcodes WHERE id= $1
`

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

const getReceptionQRCodes = `-- name: GetReceptionQRCodes :one
SELECT id, receptionform_id, qrcode, created_at FROM receptionform_qrcodes
WHERE receptionform_id = $1
`

func (q *Queries) GetReceptionQRCodes(ctx context.Context, receptionformID int32) (ReceptionformQrcode, error) {
	row := q.db.QueryRowContext(ctx, getReceptionQRCodes, receptionformID)
	var i ReceptionformQrcode
	err := row.Scan(
		&i.ID,
		&i.ReceptionformID,
		&i.Qrcode,
		&i.CreatedAt,
	)
	return i, err
}

const listReceptionFormsQRCodes = `-- name: ListReceptionFormsQRCodes :many
SELECT id, receptionform_id, qrcode, created_at FROM receptionform_qrcodes
ORDER BY id LIMIT $1
OFFSET $2
`

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

func (q *Queries) ListReceptionFormsQRCodes(ctx context.Context, arg ListReceptionFormsQRCodesParams) ([]ReceptionformQrcode, error) {
	rows, err := q.db.QueryContext(ctx, listReceptionFormsQRCodes, arg.Limit, arg.Offset)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []ReceptionformQrcode{}
	for rows.Next() {
		var i ReceptionformQrcode
		if err := rows.Scan(
			&i.ID,
			&i.ReceptionformID,
			&i.Qrcode,
			&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 updateReceptionFormQRCodes = `-- name: UpdateReceptionFormQRCodes :one
UPDATE receptionform_qrcodes
  set 
    receptionform_id=$2,            
    qrcode=$3
WHERE id = $1
RETURNING id, receptionform_id, qrcode, created_at
`

type UpdateReceptionFormQRCodesParams struct {
	ID              int64  `json:"id"`
	ReceptionformID int32  `json:"receptionform_id"`
	Qrcode          string `json:"qrcode"`
}

func (q *Queries) UpdateReceptionFormQRCodes(ctx context.Context, arg UpdateReceptionFormQRCodesParams) (ReceptionformQrcode, error) {
	row := q.db.QueryRowContext(ctx, updateReceptionFormQRCodes, arg.ID, arg.ReceptionformID, arg.Qrcode)
	var i ReceptionformQrcode
	err := row.Scan(
		&i.ID,
		&i.ReceptionformID,
		&i.Qrcode,
		&i.CreatedAt,
	)
	return i, err
}
