200 lines
5.0 KiB
Go
200 lines
5.0 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.29.0
|
|
// source: direct_deposit.sql
|
|
|
|
package dbgen
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const CreateDirectDeposit = `-- name: CreateDirectDeposit :one
|
|
INSERT INTO direct_deposits (
|
|
customer_id,
|
|
wallet_id,
|
|
amount,
|
|
bank_reference,
|
|
sender_account,
|
|
status
|
|
) VALUES (
|
|
$1, $2, $3, $4, $5, $6
|
|
) RETURNING id, customer_id, wallet_id, amount, bank_reference, sender_account, status, created_at, verified_by, verification_notes, verified_at
|
|
`
|
|
|
|
type CreateDirectDepositParams struct {
|
|
CustomerID int64 `json:"customer_id"`
|
|
WalletID int64 `json:"wallet_id"`
|
|
Amount pgtype.Numeric `json:"amount"`
|
|
BankReference string `json:"bank_reference"`
|
|
SenderAccount string `json:"sender_account"`
|
|
Status string `json:"status"`
|
|
}
|
|
|
|
func (q *Queries) CreateDirectDeposit(ctx context.Context, arg CreateDirectDepositParams) (DirectDeposit, error) {
|
|
row := q.db.QueryRow(ctx, CreateDirectDeposit,
|
|
arg.CustomerID,
|
|
arg.WalletID,
|
|
arg.Amount,
|
|
arg.BankReference,
|
|
arg.SenderAccount,
|
|
arg.Status,
|
|
)
|
|
var i DirectDeposit
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CustomerID,
|
|
&i.WalletID,
|
|
&i.Amount,
|
|
&i.BankReference,
|
|
&i.SenderAccount,
|
|
&i.Status,
|
|
&i.CreatedAt,
|
|
&i.VerifiedBy,
|
|
&i.VerificationNotes,
|
|
&i.VerifiedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const GetCustomerDirectDeposits = `-- name: GetCustomerDirectDeposits :many
|
|
SELECT id, customer_id, wallet_id, amount, bank_reference, sender_account, status, created_at, verified_by, verification_notes, verified_at FROM direct_deposits WHERE customer_id = $1 ORDER BY created_at DESC
|
|
`
|
|
|
|
func (q *Queries) GetCustomerDirectDeposits(ctx context.Context, customerID int64) ([]DirectDeposit, error) {
|
|
rows, err := q.db.Query(ctx, GetCustomerDirectDeposits, customerID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []DirectDeposit
|
|
for rows.Next() {
|
|
var i DirectDeposit
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.CustomerID,
|
|
&i.WalletID,
|
|
&i.Amount,
|
|
&i.BankReference,
|
|
&i.SenderAccount,
|
|
&i.Status,
|
|
&i.CreatedAt,
|
|
&i.VerifiedBy,
|
|
&i.VerificationNotes,
|
|
&i.VerifiedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const GetDirectDeposit = `-- name: GetDirectDeposit :one
|
|
SELECT id, customer_id, wallet_id, amount, bank_reference, sender_account, status, created_at, verified_by, verification_notes, verified_at FROM direct_deposits WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) GetDirectDeposit(ctx context.Context, id int64) (DirectDeposit, error) {
|
|
row := q.db.QueryRow(ctx, GetDirectDeposit, id)
|
|
var i DirectDeposit
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CustomerID,
|
|
&i.WalletID,
|
|
&i.Amount,
|
|
&i.BankReference,
|
|
&i.SenderAccount,
|
|
&i.Status,
|
|
&i.CreatedAt,
|
|
&i.VerifiedBy,
|
|
&i.VerificationNotes,
|
|
&i.VerifiedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const GetDirectDepositsByStatus = `-- name: GetDirectDepositsByStatus :many
|
|
SELECT id, customer_id, wallet_id, amount, bank_reference, sender_account, status, created_at, verified_by, verification_notes, verified_at FROM direct_deposits WHERE status = $1 ORDER BY created_at DESC
|
|
`
|
|
|
|
func (q *Queries) GetDirectDepositsByStatus(ctx context.Context, status string) ([]DirectDeposit, error) {
|
|
rows, err := q.db.Query(ctx, GetDirectDepositsByStatus, status)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []DirectDeposit
|
|
for rows.Next() {
|
|
var i DirectDeposit
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.CustomerID,
|
|
&i.WalletID,
|
|
&i.Amount,
|
|
&i.BankReference,
|
|
&i.SenderAccount,
|
|
&i.Status,
|
|
&i.CreatedAt,
|
|
&i.VerifiedBy,
|
|
&i.VerificationNotes,
|
|
&i.VerifiedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const UpdateDirectDeposit = `-- name: UpdateDirectDeposit :one
|
|
UPDATE direct_deposits
|
|
SET
|
|
status = $2,
|
|
verified_by = $3,
|
|
verification_notes = $4,
|
|
verified_at = $5
|
|
WHERE id = $1
|
|
RETURNING id, customer_id, wallet_id, amount, bank_reference, sender_account, status, created_at, verified_by, verification_notes, verified_at
|
|
`
|
|
|
|
type UpdateDirectDepositParams struct {
|
|
ID int64 `json:"id"`
|
|
Status string `json:"status"`
|
|
VerifiedBy pgtype.Int8 `json:"verified_by"`
|
|
VerificationNotes pgtype.Text `json:"verification_notes"`
|
|
VerifiedAt pgtype.Timestamp `json:"verified_at"`
|
|
}
|
|
|
|
func (q *Queries) UpdateDirectDeposit(ctx context.Context, arg UpdateDirectDepositParams) (DirectDeposit, error) {
|
|
row := q.db.QueryRow(ctx, UpdateDirectDeposit,
|
|
arg.ID,
|
|
arg.Status,
|
|
arg.VerifiedBy,
|
|
arg.VerificationNotes,
|
|
arg.VerifiedAt,
|
|
)
|
|
var i DirectDeposit
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CustomerID,
|
|
&i.WalletID,
|
|
&i.Amount,
|
|
&i.BankReference,
|
|
&i.SenderAccount,
|
|
&i.Status,
|
|
&i.CreatedAt,
|
|
&i.VerifiedBy,
|
|
&i.VerificationNotes,
|
|
&i.VerifiedAt,
|
|
)
|
|
return i, err
|
|
}
|