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

package db

import (
	"context"
)

const createQualityAttribute = `-- name: CreateQualityAttribute :one
INSERT INTO qualityattributes (
      description,    
      qcp1,
      qcp2,
      qcp3,
      qcp4,
      qcp5,
      receptionform
 ) VALUES (
     $1,
     $2,
     $3,
     $4,
     $5,
     $6,
     $7
 ) RETURNING id, description, qcp1, qcp2, qcp3, qcp4, qcp5, receptionform, status, created_at
`

type CreateQualityAttributeParams struct {
	Description   string `json:"description"`
	Qcp1          bool   `json:"qcp1"`
	Qcp2          bool   `json:"qcp2"`
	Qcp3          bool   `json:"qcp3"`
	Qcp4          bool   `json:"qcp4"`
	Qcp5          bool   `json:"qcp5"`
	Receptionform bool   `json:"receptionform"`
}

func (q *Queries) CreateQualityAttribute(ctx context.Context, arg CreateQualityAttributeParams) (Qualityattribute, error) {
	row := q.db.QueryRowContext(ctx, createQualityAttribute,
		arg.Description,
		arg.Qcp1,
		arg.Qcp2,
		arg.Qcp3,
		arg.Qcp4,
		arg.Qcp5,
		arg.Receptionform,
	)
	var i Qualityattribute
	err := row.Scan(
		&i.ID,
		&i.Description,
		&i.Qcp1,
		&i.Qcp2,
		&i.Qcp3,
		&i.Qcp4,
		&i.Qcp5,
		&i.Receptionform,
		&i.Status,
		&i.CreatedAt,
	)
	return i, err
}

const deleteQualityAttribute = `-- name: DeleteQualityAttribute :exec
DELETE FROM qualityattributes WHERE id= $1
`

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

const getQualityAttribute = `-- name: GetQualityAttribute :one
SELECT id, description, qcp1, qcp2, qcp3, qcp4, qcp5, receptionform, status, created_at FROM qualityattributes
WHERE id = $1 LIMIT 1
`

func (q *Queries) GetQualityAttribute(ctx context.Context, id int64) (Qualityattribute, error) {
	row := q.db.QueryRowContext(ctx, getQualityAttribute, id)
	var i Qualityattribute
	err := row.Scan(
		&i.ID,
		&i.Description,
		&i.Qcp1,
		&i.Qcp2,
		&i.Qcp3,
		&i.Qcp4,
		&i.Qcp5,
		&i.Receptionform,
		&i.Status,
		&i.CreatedAt,
	)
	return i, err
}

const listQCP1QualityAttributes = `-- name: ListQCP1QualityAttributes :many
SELECT id, description, qcp1, qcp2, qcp3, qcp4, qcp5, receptionform, status, created_at FROM qualityattributes
WHERE qcp1 = true
`

func (q *Queries) ListQCP1QualityAttributes(ctx context.Context) ([]Qualityattribute, error) {
	rows, err := q.db.QueryContext(ctx, listQCP1QualityAttributes)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Qualityattribute{}
	for rows.Next() {
		var i Qualityattribute
		if err := rows.Scan(
			&i.ID,
			&i.Description,
			&i.Qcp1,
			&i.Qcp2,
			&i.Qcp3,
			&i.Qcp4,
			&i.Qcp5,
			&i.Receptionform,
			&i.Status,
			&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 listQCP2QualityAttributes = `-- name: ListQCP2QualityAttributes :many
SELECT id, description, qcp1, qcp2, qcp3, qcp4, qcp5, receptionform, status, created_at FROM qualityattributes
WHERE qcp2 = true
`

func (q *Queries) ListQCP2QualityAttributes(ctx context.Context) ([]Qualityattribute, error) {
	rows, err := q.db.QueryContext(ctx, listQCP2QualityAttributes)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Qualityattribute{}
	for rows.Next() {
		var i Qualityattribute
		if err := rows.Scan(
			&i.ID,
			&i.Description,
			&i.Qcp1,
			&i.Qcp2,
			&i.Qcp3,
			&i.Qcp4,
			&i.Qcp5,
			&i.Receptionform,
			&i.Status,
			&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 listQCP3QualityAttributes = `-- name: ListQCP3QualityAttributes :many
SELECT id, description, qcp1, qcp2, qcp3, qcp4, qcp5, receptionform, status, created_at FROM qualityattributes
WHERE qcp3 = true
`

func (q *Queries) ListQCP3QualityAttributes(ctx context.Context) ([]Qualityattribute, error) {
	rows, err := q.db.QueryContext(ctx, listQCP3QualityAttributes)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Qualityattribute{}
	for rows.Next() {
		var i Qualityattribute
		if err := rows.Scan(
			&i.ID,
			&i.Description,
			&i.Qcp1,
			&i.Qcp2,
			&i.Qcp3,
			&i.Qcp4,
			&i.Qcp5,
			&i.Receptionform,
			&i.Status,
			&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 listQCP4QualityAttributes = `-- name: ListQCP4QualityAttributes :many
SELECT id, description, qcp1, qcp2, qcp3, qcp4, qcp5, receptionform, status, created_at FROM qualityattributes
WHERE qcp4 = true
`

func (q *Queries) ListQCP4QualityAttributes(ctx context.Context) ([]Qualityattribute, error) {
	rows, err := q.db.QueryContext(ctx, listQCP4QualityAttributes)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Qualityattribute{}
	for rows.Next() {
		var i Qualityattribute
		if err := rows.Scan(
			&i.ID,
			&i.Description,
			&i.Qcp1,
			&i.Qcp2,
			&i.Qcp3,
			&i.Qcp4,
			&i.Qcp5,
			&i.Receptionform,
			&i.Status,
			&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 listQCP5QualityAttributes = `-- name: ListQCP5QualityAttributes :many
SELECT id, description, qcp1, qcp2, qcp3, qcp4, qcp5, receptionform, status, created_at FROM qualityattributes
WHERE qcp5 = true
`

func (q *Queries) ListQCP5QualityAttributes(ctx context.Context) ([]Qualityattribute, error) {
	rows, err := q.db.QueryContext(ctx, listQCP5QualityAttributes)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Qualityattribute{}
	for rows.Next() {
		var i Qualityattribute
		if err := rows.Scan(
			&i.ID,
			&i.Description,
			&i.Qcp1,
			&i.Qcp2,
			&i.Qcp3,
			&i.Qcp4,
			&i.Qcp5,
			&i.Receptionform,
			&i.Status,
			&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 listQualityAttributes = `-- name: ListQualityAttributes :many
SELECT id, description, qcp1, qcp2, qcp3, qcp4, qcp5, receptionform, status, created_at FROM qualityattributes
`

func (q *Queries) ListQualityAttributes(ctx context.Context) ([]Qualityattribute, error) {
	rows, err := q.db.QueryContext(ctx, listQualityAttributes)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Qualityattribute{}
	for rows.Next() {
		var i Qualityattribute
		if err := rows.Scan(
			&i.ID,
			&i.Description,
			&i.Qcp1,
			&i.Qcp2,
			&i.Qcp3,
			&i.Qcp4,
			&i.Qcp5,
			&i.Receptionform,
			&i.Status,
			&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 listReceptionQualityAttributes = `-- name: ListReceptionQualityAttributes :many
SELECT id, description, qcp1, qcp2, qcp3, qcp4, qcp5, receptionform, status, created_at FROM qualityattributes
WHERE receptionform = true
`

func (q *Queries) ListReceptionQualityAttributes(ctx context.Context) ([]Qualityattribute, error) {
	rows, err := q.db.QueryContext(ctx, listReceptionQualityAttributes)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Qualityattribute{}
	for rows.Next() {
		var i Qualityattribute
		if err := rows.Scan(
			&i.ID,
			&i.Description,
			&i.Qcp1,
			&i.Qcp2,
			&i.Qcp3,
			&i.Qcp4,
			&i.Qcp5,
			&i.Receptionform,
			&i.Status,
			&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 totalQualityAttributes = `-- name: TotalQualityAttributes :one
SELECT SUM(id) FROM qualityattributes
`

func (q *Queries) TotalQualityAttributes(ctx context.Context) (int64, error) {
	row := q.db.QueryRowContext(ctx, totalQualityAttributes)
	var sum int64
	err := row.Scan(&sum)
	return sum, err
}

const updateQualityAttribute = `-- name: UpdateQualityAttribute :one
UPDATE qualityattributes
  set 
   description = $2,    
   qcp1 = $3,
   qcp2 = $4,
   qcp3 = $5,
   qcp4 = $6,
   qcp5 = $7,
   receptionform = $8
WHERE id = $1
RETURNING id, description, qcp1, qcp2, qcp3, qcp4, qcp5, receptionform, status, created_at
`

type UpdateQualityAttributeParams struct {
	ID            int64  `json:"id"`
	Description   string `json:"description"`
	Qcp1          bool   `json:"qcp1"`
	Qcp2          bool   `json:"qcp2"`
	Qcp3          bool   `json:"qcp3"`
	Qcp4          bool   `json:"qcp4"`
	Qcp5          bool   `json:"qcp5"`
	Receptionform bool   `json:"receptionform"`
}

func (q *Queries) UpdateQualityAttribute(ctx context.Context, arg UpdateQualityAttributeParams) (Qualityattribute, error) {
	row := q.db.QueryRowContext(ctx, updateQualityAttribute,
		arg.ID,
		arg.Description,
		arg.Qcp1,
		arg.Qcp2,
		arg.Qcp3,
		arg.Qcp4,
		arg.Qcp5,
		arg.Receptionform,
	)
	var i Qualityattribute
	err := row.Scan(
		&i.ID,
		&i.Description,
		&i.Qcp1,
		&i.Qcp2,
		&i.Qcp3,
		&i.Qcp4,
		&i.Qcp5,
		&i.Receptionform,
		&i.Status,
		&i.CreatedAt,
	)
	return i, err
}
