231 lines
5.5 KiB
Go
231 lines
5.5 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.21.0
|
|
// source: payment.sql
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
)
|
|
|
|
const createPayment = `-- name: CreatePayment :one
|
|
INSERT INTO payments (
|
|
"customerID",
|
|
"paymentCategory",
|
|
bankname,
|
|
"IBAN",
|
|
"BIC",
|
|
"paypalAccount",
|
|
"paypalID",
|
|
"paymentSystem",
|
|
"type",
|
|
creator,
|
|
changer
|
|
) VALUES (
|
|
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11
|
|
) RETURNING "ID", "customerID", "paymentCategory", bankname, "IBAN", "BIC", "paypalAccount", "paypalID", "paymentSystem", type, creator, created, changer, changed
|
|
`
|
|
|
|
type CreatePaymentParams struct {
|
|
CustomerID int64 `json:"customerID"`
|
|
PaymentCategory string `json:"paymentCategory"`
|
|
Bankname sql.NullString `json:"bankname"`
|
|
IBAN sql.NullString `json:"IBAN"`
|
|
BIC sql.NullString `json:"BIC"`
|
|
PaypalAccount sql.NullString `json:"paypalAccount"`
|
|
PaypalID sql.NullString `json:"paypalID"`
|
|
PaymentSystem sql.NullString `json:"paymentSystem"`
|
|
Type string `json:"type"`
|
|
Creator string `json:"creator"`
|
|
Changer string `json:"changer"`
|
|
}
|
|
|
|
func (q *Queries) CreatePayment(ctx context.Context, arg CreatePaymentParams) (Payment, error) {
|
|
row := q.db.QueryRowContext(ctx, createPayment,
|
|
arg.CustomerID,
|
|
arg.PaymentCategory,
|
|
arg.Bankname,
|
|
arg.IBAN,
|
|
arg.BIC,
|
|
arg.PaypalAccount,
|
|
arg.PaypalID,
|
|
arg.PaymentSystem,
|
|
arg.Type,
|
|
arg.Creator,
|
|
arg.Changer,
|
|
)
|
|
var i Payment
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CustomerID,
|
|
&i.PaymentCategory,
|
|
&i.Bankname,
|
|
&i.IBAN,
|
|
&i.BIC,
|
|
&i.PaypalAccount,
|
|
&i.PaypalID,
|
|
&i.PaymentSystem,
|
|
&i.Type,
|
|
&i.Creator,
|
|
&i.Created,
|
|
&i.Changer,
|
|
&i.Changed,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const deletePayment = `-- name: DeletePayment :exec
|
|
DELETE FROM payments
|
|
WHERE "ID" = $1
|
|
`
|
|
|
|
func (q *Queries) DeletePayment(ctx context.Context, id int64) error {
|
|
_, err := q.db.ExecContext(ctx, deletePayment, id)
|
|
return err
|
|
}
|
|
|
|
const getPayment = `-- name: GetPayment :one
|
|
SELECT "ID", "customerID", "paymentCategory", bankname, "IBAN", "BIC", "paypalAccount", "paypalID", "paymentSystem", type, creator, created, changer, changed FROM payments
|
|
WHERE "ID" = $1 LIMIT 1
|
|
`
|
|
|
|
func (q *Queries) GetPayment(ctx context.Context, id int64) (Payment, error) {
|
|
row := q.db.QueryRowContext(ctx, getPayment, id)
|
|
var i Payment
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CustomerID,
|
|
&i.PaymentCategory,
|
|
&i.Bankname,
|
|
&i.IBAN,
|
|
&i.BIC,
|
|
&i.PaypalAccount,
|
|
&i.PaypalID,
|
|
&i.PaymentSystem,
|
|
&i.Type,
|
|
&i.Creator,
|
|
&i.Created,
|
|
&i.Changer,
|
|
&i.Changed,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listPayments = `-- name: ListPayments :many
|
|
SELECT "ID", "customerID", "paymentCategory", bankname, "IBAN", "BIC", "paypalAccount", "paypalID", "paymentSystem", type, creator, created, changer, changed FROM payments
|
|
ORDER BY "paymentCategory"
|
|
LIMIT $1
|
|
OFFSET $2
|
|
`
|
|
|
|
type ListPaymentsParams struct {
|
|
Limit int32 `json:"limit"`
|
|
Offset int32 `json:"offset"`
|
|
}
|
|
|
|
func (q *Queries) ListPayments(ctx context.Context, arg ListPaymentsParams) ([]Payment, error) {
|
|
rows, err := q.db.QueryContext(ctx, listPayments, arg.Limit, arg.Offset)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []Payment{}
|
|
for rows.Next() {
|
|
var i Payment
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.CustomerID,
|
|
&i.PaymentCategory,
|
|
&i.Bankname,
|
|
&i.IBAN,
|
|
&i.BIC,
|
|
&i.PaypalAccount,
|
|
&i.PaypalID,
|
|
&i.PaymentSystem,
|
|
&i.Type,
|
|
&i.Creator,
|
|
&i.Created,
|
|
&i.Changer,
|
|
&i.Changed,
|
|
); 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 updatePayment = `-- name: UpdatePayment :one
|
|
UPDATE payments
|
|
SET
|
|
"customerID" = COALESCE($3, "customerID"),
|
|
"paymentCategory" = COALESCE($4, "paymentCategory"),
|
|
bankname = COALESCE($5, bankname),
|
|
"IBAN" = COALESCE($6, "IBAN"),
|
|
"BIC" = COALESCE($7, "BIC"),
|
|
"paypalAccount" = COALESCE($8, "paypalAccount"),
|
|
"paypalID" = COALESCE($9, "paypalID"),
|
|
"paymentSystem" = COALESCE($10, "paymentSystem"),
|
|
"type" = COALESCE($11, "type"),
|
|
changer = $2,
|
|
changed = now()
|
|
WHERE "ID" = $1
|
|
RETURNING "ID", "customerID", "paymentCategory", bankname, "IBAN", "BIC", "paypalAccount", "paypalID", "paymentSystem", type, creator, created, changer, changed
|
|
`
|
|
|
|
type UpdatePaymentParams struct {
|
|
ID int64 `json:"ID"`
|
|
Changer string `json:"changer"`
|
|
Customerid sql.NullInt64 `json:"customerid"`
|
|
Paymentcategory sql.NullString `json:"paymentcategory"`
|
|
Bankname sql.NullString `json:"bankname"`
|
|
Iban sql.NullString `json:"iban"`
|
|
Bic sql.NullString `json:"bic"`
|
|
Paypalaccount sql.NullString `json:"paypalaccount"`
|
|
Paypalid sql.NullString `json:"paypalid"`
|
|
Paymentsystem sql.NullString `json:"paymentsystem"`
|
|
Type sql.NullString `json:"type"`
|
|
}
|
|
|
|
func (q *Queries) UpdatePayment(ctx context.Context, arg UpdatePaymentParams) (Payment, error) {
|
|
row := q.db.QueryRowContext(ctx, updatePayment,
|
|
arg.ID,
|
|
arg.Changer,
|
|
arg.Customerid,
|
|
arg.Paymentcategory,
|
|
arg.Bankname,
|
|
arg.Iban,
|
|
arg.Bic,
|
|
arg.Paypalaccount,
|
|
arg.Paypalid,
|
|
arg.Paymentsystem,
|
|
arg.Type,
|
|
)
|
|
var i Payment
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CustomerID,
|
|
&i.PaymentCategory,
|
|
&i.Bankname,
|
|
&i.IBAN,
|
|
&i.BIC,
|
|
&i.PaypalAccount,
|
|
&i.PaypalID,
|
|
&i.PaymentSystem,
|
|
&i.Type,
|
|
&i.Creator,
|
|
&i.Created,
|
|
&i.Changer,
|
|
&i.Changed,
|
|
)
|
|
return i, err
|
|
}
|