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

package db

import (
	"context"
	"database/sql"
)

const createQcp1Recommendation = `-- name: CreateQcp1Recommendation :one
INSERT INTO qcp1_recommendation (
    qcp1_id,
    status,
    netweightrejected,
    netweightpassed,
    other
 ) VALUES (
     $1, 
     $2, 
     $3,
     $4,
     $5
    ) 
RETURNING id, qcp1_id, status, netweightrejected, netweightpassed, other, created_at
`

type CreateQcp1RecommendationParams struct {
	Qcp1ID            int32           `json:"qcp1_id"`
	Status            string          `json:"status"`
	Netweightrejected float64         `json:"netweightrejected"`
	Netweightpassed   sql.NullFloat64 `json:"netweightpassed"`
	Other             sql.NullString  `json:"other"`
}

func (q *Queries) CreateQcp1Recommendation(ctx context.Context, arg CreateQcp1RecommendationParams) (Qcp1Recommendation, error) {
	row := q.db.QueryRowContext(ctx, createQcp1Recommendation,
		arg.Qcp1ID,
		arg.Status,
		arg.Netweightrejected,
		arg.Netweightpassed,
		arg.Other,
	)
	var i Qcp1Recommendation
	err := row.Scan(
		&i.ID,
		&i.Qcp1ID,
		&i.Status,
		&i.Netweightrejected,
		&i.Netweightpassed,
		&i.Other,
		&i.CreatedAt,
	)
	return i, err
}

const deleteQcp1Recommendation = `-- name: DeleteQcp1Recommendation :exec
DELETE FROM qcp1_recommendation WHERE id= $1
`

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

const getQcp1Recommendation = `-- name: GetQcp1Recommendation :one
SELECT id, qcp1_id, status, netweightrejected, netweightpassed, other, created_at FROM qcp1_recommendation
WHERE qcp1_id = $1 LIMIT 1
`

func (q *Queries) GetQcp1Recommendation(ctx context.Context, qcp1ID int32) (Qcp1Recommendation, error) {
	row := q.db.QueryRowContext(ctx, getQcp1Recommendation, qcp1ID)
	var i Qcp1Recommendation
	err := row.Scan(
		&i.ID,
		&i.Qcp1ID,
		&i.Status,
		&i.Netweightrejected,
		&i.Netweightpassed,
		&i.Other,
		&i.CreatedAt,
	)
	return i, err
}

const listQcp1Recommendation = `-- name: ListQcp1Recommendation :many
SELECT id, qcp1_id, status, netweightrejected, netweightpassed, other, created_at FROM qcp1_recommendation
ORDER BY id LIMIT $1
OFFSET $2
`

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

func (q *Queries) ListQcp1Recommendation(ctx context.Context, arg ListQcp1RecommendationParams) ([]Qcp1Recommendation, error) {
	rows, err := q.db.QueryContext(ctx, listQcp1Recommendation, arg.Limit, arg.Offset)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Qcp1Recommendation{}
	for rows.Next() {
		var i Qcp1Recommendation
		if err := rows.Scan(
			&i.ID,
			&i.Qcp1ID,
			&i.Status,
			&i.Netweightrejected,
			&i.Netweightpassed,
			&i.Other,
			&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 updateQcp1Recommendation = `-- name: UpdateQcp1Recommendation :one
UPDATE qcp1_recommendation
  set 
     qcp1_id = $2,
     status = $3,
     netweightrejected = $4,
     netweightpassed = $5,
     other  = $6
WHERE id = $1
RETURNING id, qcp1_id, status, netweightrejected, netweightpassed, other, created_at
`

type UpdateQcp1RecommendationParams struct {
	ID                int64           `json:"id"`
	Qcp1ID            int32           `json:"qcp1_id"`
	Status            string          `json:"status"`
	Netweightrejected float64         `json:"netweightrejected"`
	Netweightpassed   sql.NullFloat64 `json:"netweightpassed"`
	Other             sql.NullString  `json:"other"`
}

func (q *Queries) UpdateQcp1Recommendation(ctx context.Context, arg UpdateQcp1RecommendationParams) (Qcp1Recommendation, error) {
	row := q.db.QueryRowContext(ctx, updateQcp1Recommendation,
		arg.ID,
		arg.Qcp1ID,
		arg.Status,
		arg.Netweightrejected,
		arg.Netweightpassed,
		arg.Other,
	)
	var i Qcp1Recommendation
	err := row.Scan(
		&i.ID,
		&i.Qcp1ID,
		&i.Status,
		&i.Netweightrejected,
		&i.Netweightpassed,
		&i.Other,
		&i.CreatedAt,
	)
	return i, err
}
