222 lines
5.3 KiB
Go
222 lines
5.3 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.22.0
|
|
// source: payment.sql
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
)
|
|
|
|
const createPayment = `-- name: CreatePayment :one
|
|
INSERT INTO payments (
|
|
"account_id",
|
|
"payment_category",
|
|
"bankname",
|
|
"IBAN",
|
|
"BIC",
|
|
"paypal_account",
|
|
"paypal_id",
|
|
"payment_system",
|
|
"type",
|
|
"creator",
|
|
"changer"
|
|
) VALUES (
|
|
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11
|
|
) RETURNING id, account_id, payment_category, bankname, "IBAN", "BIC", paypal_account, paypal_id, payment_system, type, creator, created, changer, changed
|
|
`
|
|
|
|
type CreatePaymentParams struct {
|
|
AccountID uint64 `json:"account_id"`
|
|
PaymentCategory string `json:"payment_category"`
|
|
Bankname sql.NullString `json:"bankname"`
|
|
IBAN sql.NullString `json:"IBAN"`
|
|
BIC sql.NullString `json:"BIC"`
|
|
PaypalAccount sql.NullString `json:"paypal_account"`
|
|
PaypalID sql.NullString `json:"paypal_id"`
|
|
PaymentSystem sql.NullString `json:"payment_system"`
|
|
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.AccountID,
|
|
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.AccountID,
|
|
&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 uint64) error {
|
|
_, err := q.db.ExecContext(ctx, deletePayment, id)
|
|
return err
|
|
}
|
|
|
|
const getPayment = `-- name: GetPayment :one
|
|
SELECT id, account_id, payment_category, bankname, "IBAN", "BIC", paypal_account, paypal_id, payment_system, type, creator, created, changer, changed FROM payments
|
|
WHERE "id" = $1 LIMIT 1
|
|
`
|
|
|
|
func (q *Queries) GetPayment(ctx context.Context, id uint64) (Payment, error) {
|
|
row := q.db.QueryRowContext(ctx, getPayment, id)
|
|
var i Payment
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.AccountID,
|
|
&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, account_id, payment_category, bankname, "IBAN", "BIC", paypal_account, paypal_id, payment_system, type, creator, created, changer, changed FROM payments
|
|
WHERE "account_id" = $1
|
|
ORDER BY "payment_category"
|
|
`
|
|
|
|
func (q *Queries) ListPayments(ctx context.Context, accountID uint64) ([]Payment, error) {
|
|
rows, err := q.db.QueryContext(ctx, listPayments, accountID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []Payment{}
|
|
for rows.Next() {
|
|
var i Payment
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.AccountID,
|
|
&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
|
|
"payment_category" = COALESCE($1, "payment_category"),
|
|
"bankname" = COALESCE($2, "bankname"),
|
|
"IBAN" = COALESCE($3, "IBAN"),
|
|
"BIC" = COALESCE($4, "BIC"),
|
|
"paypal_account" = COALESCE($5, "paypal_account"),
|
|
"paypal_id" = COALESCE($6, "paypal_id"),
|
|
"payment_system" = COALESCE($7, "payment_system"),
|
|
"type" = COALESCE($8, "type"),
|
|
"changer" = $9,
|
|
"changed" = now()
|
|
WHERE "id" = $10
|
|
RETURNING id, account_id, payment_category, bankname, "IBAN", "BIC", paypal_account, paypal_id, payment_system, type, creator, created, changer, changed
|
|
`
|
|
|
|
type UpdatePaymentParams struct {
|
|
PaymentCategory sql.NullString `json:"payment_category"`
|
|
Bankname sql.NullString `json:"bankname"`
|
|
Iban sql.NullString `json:"iban"`
|
|
Bic sql.NullString `json:"bic"`
|
|
PaypalAccount sql.NullString `json:"paypal_account"`
|
|
PaypalID sql.NullString `json:"paypal_id"`
|
|
PaymentSystem sql.NullString `json:"payment_system"`
|
|
Type sql.NullString `json:"type"`
|
|
Changer string `json:"changer"`
|
|
ID uint64 `json:"id"`
|
|
}
|
|
|
|
func (q *Queries) UpdatePayment(ctx context.Context, arg UpdatePaymentParams) (Payment, error) {
|
|
row := q.db.QueryRowContext(ctx, updatePayment,
|
|
arg.PaymentCategory,
|
|
arg.Bankname,
|
|
arg.Iban,
|
|
arg.Bic,
|
|
arg.PaypalAccount,
|
|
arg.PaypalID,
|
|
arg.PaymentSystem,
|
|
arg.Type,
|
|
arg.Changer,
|
|
arg.ID,
|
|
)
|
|
var i Payment
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.AccountID,
|
|
&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
|
|
}
|