294 lines
7.1 KiB
Go
294 lines
7.1 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.28.0
|
|
// source: transactions.sql
|
|
|
|
package dbgen
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const CreateTransaction = `-- name: CreateTransaction :one
|
|
INSERT INTO transactions (
|
|
amount,
|
|
branch_id,
|
|
cashier_id,
|
|
bet_id,
|
|
type,
|
|
payment_option,
|
|
full_name,
|
|
phone_number,
|
|
bank_code,
|
|
beneficiary_name,
|
|
account_name,
|
|
account_number,
|
|
reference_number,
|
|
number_of_outcomes,
|
|
branch_name,
|
|
branch_location,
|
|
company_id,
|
|
cashier_name
|
|
)
|
|
VALUES (
|
|
$1,
|
|
$2,
|
|
$3,
|
|
$4,
|
|
$5,
|
|
$6,
|
|
$7,
|
|
$8,
|
|
$9,
|
|
$10,
|
|
$11,
|
|
$12,
|
|
$13,
|
|
$14,
|
|
$15,
|
|
$16,
|
|
$17,
|
|
$18
|
|
)
|
|
RETURNING id, amount, branch_id, company_id, cashier_id, cashier_name, bet_id, number_of_outcomes, type, payment_option, full_name, phone_number, bank_code, beneficiary_name, account_name, account_number, reference_number, verified, approved_by, approver_name, branch_location, branch_name, created_at, updated_at
|
|
`
|
|
|
|
type CreateTransactionParams struct {
|
|
Amount int64 `json:"amount"`
|
|
BranchID int64 `json:"branch_id"`
|
|
CashierID int64 `json:"cashier_id"`
|
|
BetID int64 `json:"bet_id"`
|
|
Type int64 `json:"type"`
|
|
PaymentOption int64 `json:"payment_option"`
|
|
FullName string `json:"full_name"`
|
|
PhoneNumber string `json:"phone_number"`
|
|
BankCode string `json:"bank_code"`
|
|
BeneficiaryName string `json:"beneficiary_name"`
|
|
AccountName string `json:"account_name"`
|
|
AccountNumber string `json:"account_number"`
|
|
ReferenceNumber string `json:"reference_number"`
|
|
NumberOfOutcomes int64 `json:"number_of_outcomes"`
|
|
BranchName string `json:"branch_name"`
|
|
BranchLocation string `json:"branch_location"`
|
|
CompanyID int64 `json:"company_id"`
|
|
CashierName string `json:"cashier_name"`
|
|
}
|
|
|
|
func (q *Queries) CreateTransaction(ctx context.Context, arg CreateTransactionParams) (Transaction, error) {
|
|
row := q.db.QueryRow(ctx, CreateTransaction,
|
|
arg.Amount,
|
|
arg.BranchID,
|
|
arg.CashierID,
|
|
arg.BetID,
|
|
arg.Type,
|
|
arg.PaymentOption,
|
|
arg.FullName,
|
|
arg.PhoneNumber,
|
|
arg.BankCode,
|
|
arg.BeneficiaryName,
|
|
arg.AccountName,
|
|
arg.AccountNumber,
|
|
arg.ReferenceNumber,
|
|
arg.NumberOfOutcomes,
|
|
arg.BranchName,
|
|
arg.BranchLocation,
|
|
arg.CompanyID,
|
|
arg.CashierName,
|
|
)
|
|
var i Transaction
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Amount,
|
|
&i.BranchID,
|
|
&i.CompanyID,
|
|
&i.CashierID,
|
|
&i.CashierName,
|
|
&i.BetID,
|
|
&i.NumberOfOutcomes,
|
|
&i.Type,
|
|
&i.PaymentOption,
|
|
&i.FullName,
|
|
&i.PhoneNumber,
|
|
&i.BankCode,
|
|
&i.BeneficiaryName,
|
|
&i.AccountName,
|
|
&i.AccountNumber,
|
|
&i.ReferenceNumber,
|
|
&i.Verified,
|
|
&i.ApprovedBy,
|
|
&i.ApproverName,
|
|
&i.BranchLocation,
|
|
&i.BranchName,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const GetAllTransactions = `-- name: GetAllTransactions :many
|
|
SELECT id, amount, branch_id, company_id, cashier_id, cashier_name, bet_id, number_of_outcomes, type, payment_option, full_name, phone_number, bank_code, beneficiary_name, account_name, account_number, reference_number, verified, approved_by, approver_name, branch_location, branch_name, created_at, updated_at
|
|
FROM transactions
|
|
`
|
|
|
|
func (q *Queries) GetAllTransactions(ctx context.Context) ([]Transaction, error) {
|
|
rows, err := q.db.Query(ctx, GetAllTransactions)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Transaction
|
|
for rows.Next() {
|
|
var i Transaction
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Amount,
|
|
&i.BranchID,
|
|
&i.CompanyID,
|
|
&i.CashierID,
|
|
&i.CashierName,
|
|
&i.BetID,
|
|
&i.NumberOfOutcomes,
|
|
&i.Type,
|
|
&i.PaymentOption,
|
|
&i.FullName,
|
|
&i.PhoneNumber,
|
|
&i.BankCode,
|
|
&i.BeneficiaryName,
|
|
&i.AccountName,
|
|
&i.AccountNumber,
|
|
&i.ReferenceNumber,
|
|
&i.Verified,
|
|
&i.ApprovedBy,
|
|
&i.ApproverName,
|
|
&i.BranchLocation,
|
|
&i.BranchName,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const GetTransactionByBranch = `-- name: GetTransactionByBranch :many
|
|
SELECT id, amount, branch_id, company_id, cashier_id, cashier_name, bet_id, number_of_outcomes, type, payment_option, full_name, phone_number, bank_code, beneficiary_name, account_name, account_number, reference_number, verified, approved_by, approver_name, branch_location, branch_name, created_at, updated_at
|
|
FROM transactions
|
|
WHERE branch_id = $1
|
|
`
|
|
|
|
func (q *Queries) GetTransactionByBranch(ctx context.Context, branchID int64) ([]Transaction, error) {
|
|
rows, err := q.db.Query(ctx, GetTransactionByBranch, branchID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Transaction
|
|
for rows.Next() {
|
|
var i Transaction
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Amount,
|
|
&i.BranchID,
|
|
&i.CompanyID,
|
|
&i.CashierID,
|
|
&i.CashierName,
|
|
&i.BetID,
|
|
&i.NumberOfOutcomes,
|
|
&i.Type,
|
|
&i.PaymentOption,
|
|
&i.FullName,
|
|
&i.PhoneNumber,
|
|
&i.BankCode,
|
|
&i.BeneficiaryName,
|
|
&i.AccountName,
|
|
&i.AccountNumber,
|
|
&i.ReferenceNumber,
|
|
&i.Verified,
|
|
&i.ApprovedBy,
|
|
&i.ApproverName,
|
|
&i.BranchLocation,
|
|
&i.BranchName,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const GetTransactionByID = `-- name: GetTransactionByID :one
|
|
SELECT id, amount, branch_id, company_id, cashier_id, cashier_name, bet_id, number_of_outcomes, type, payment_option, full_name, phone_number, bank_code, beneficiary_name, account_name, account_number, reference_number, verified, approved_by, approver_name, branch_location, branch_name, created_at, updated_at
|
|
FROM transactions
|
|
WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) GetTransactionByID(ctx context.Context, id int64) (Transaction, error) {
|
|
row := q.db.QueryRow(ctx, GetTransactionByID, id)
|
|
var i Transaction
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Amount,
|
|
&i.BranchID,
|
|
&i.CompanyID,
|
|
&i.CashierID,
|
|
&i.CashierName,
|
|
&i.BetID,
|
|
&i.NumberOfOutcomes,
|
|
&i.Type,
|
|
&i.PaymentOption,
|
|
&i.FullName,
|
|
&i.PhoneNumber,
|
|
&i.BankCode,
|
|
&i.BeneficiaryName,
|
|
&i.AccountName,
|
|
&i.AccountNumber,
|
|
&i.ReferenceNumber,
|
|
&i.Verified,
|
|
&i.ApprovedBy,
|
|
&i.ApproverName,
|
|
&i.BranchLocation,
|
|
&i.BranchName,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const UpdateTransactionVerified = `-- name: UpdateTransactionVerified :exec
|
|
UPDATE transactions
|
|
SET verified = $2,
|
|
approved_by = $3,
|
|
approver_name = $4,
|
|
updated_at = CURRENT_TIMESTAMP
|
|
WHERE id = $1
|
|
`
|
|
|
|
type UpdateTransactionVerifiedParams struct {
|
|
ID int64 `json:"id"`
|
|
Verified bool `json:"verified"`
|
|
ApprovedBy pgtype.Int8 `json:"approved_by"`
|
|
ApproverName pgtype.Text `json:"approver_name"`
|
|
}
|
|
|
|
func (q *Queries) UpdateTransactionVerified(ctx context.Context, arg UpdateTransactionVerifiedParams) error {
|
|
_, err := q.db.Exec(ctx, UpdateTransactionVerified,
|
|
arg.ID,
|
|
arg.Verified,
|
|
arg.ApprovedBy,
|
|
arg.ApproverName,
|
|
)
|
|
return err
|
|
}
|