Yimaru-BackEnd/gen/db/transactions.sql.go

335 lines
8.3 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.29.0
// source: transactions.sql
package dbgen
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const CreateShopTransaction = `-- name: CreateShopTransaction :one
INSERT INTO shop_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 CreateShopTransactionParams struct {
Amount int64 `json:"amount"`
BranchID int64 `json:"branch_id"`
CashierID pgtype.Int8 `json:"cashier_id"`
BetID pgtype.Int8 `json:"bet_id"`
Type pgtype.Int8 `json:"type"`
PaymentOption pgtype.Int8 `json:"payment_option"`
FullName pgtype.Text `json:"full_name"`
PhoneNumber pgtype.Text `json:"phone_number"`
BankCode pgtype.Text `json:"bank_code"`
BeneficiaryName pgtype.Text `json:"beneficiary_name"`
AccountName pgtype.Text `json:"account_name"`
AccountNumber pgtype.Text `json:"account_number"`
ReferenceNumber pgtype.Text `json:"reference_number"`
NumberOfOutcomes pgtype.Int8 `json:"number_of_outcomes"`
BranchName pgtype.Text `json:"branch_name"`
BranchLocation pgtype.Text `json:"branch_location"`
CompanyID pgtype.Int8 `json:"company_id"`
CashierName pgtype.Text `json:"cashier_name"`
}
func (q *Queries) CreateShopTransaction(ctx context.Context, arg CreateShopTransactionParams) (ShopTransaction, error) {
row := q.db.QueryRow(ctx, CreateShopTransaction,
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 ShopTransaction
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 GetAllShopTransactions = `-- name: GetAllShopTransactions :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 shop_transactions
wHERE (
branch_id = $1
OR $1 IS NULL
)
AND (
company_id = $2
OR $2 IS NULL
)
AND (
cashier_id = $3
OR $3 IS NULL
)
AND (
full_name ILIKE '%' || $4 || '%'
OR phone_number ILIKE '%' || $4 || '%'
OR $4 IS NULL
)
AND (
created_at > $5
OR $5 IS NULL
)
AND (
created_at < $6
OR $6 IS NULL
)
`
type GetAllShopTransactionsParams struct {
BranchID pgtype.Int8 `json:"branch_id"`
CompanyID pgtype.Int8 `json:"company_id"`
CashierID pgtype.Int8 `json:"cashier_id"`
Query pgtype.Text `json:"query"`
CreatedBefore pgtype.Timestamp `json:"created_before"`
CreatedAfter pgtype.Timestamp `json:"created_after"`
}
func (q *Queries) GetAllShopTransactions(ctx context.Context, arg GetAllShopTransactionsParams) ([]ShopTransaction, error) {
rows, err := q.db.Query(ctx, GetAllShopTransactions,
arg.BranchID,
arg.CompanyID,
arg.CashierID,
arg.Query,
arg.CreatedBefore,
arg.CreatedAfter,
)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ShopTransaction
for rows.Next() {
var i ShopTransaction
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 GetShopTransactionByBranch = `-- name: GetShopTransactionByBranch :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 shop_transactions
WHERE branch_id = $1
`
func (q *Queries) GetShopTransactionByBranch(ctx context.Context, branchID int64) ([]ShopTransaction, error) {
rows, err := q.db.Query(ctx, GetShopTransactionByBranch, branchID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ShopTransaction
for rows.Next() {
var i ShopTransaction
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 GetShopTransactionByID = `-- name: GetShopTransactionByID :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 shop_transactions
WHERE id = $1
`
func (q *Queries) GetShopTransactionByID(ctx context.Context, id int64) (ShopTransaction, error) {
row := q.db.QueryRow(ctx, GetShopTransactionByID, id)
var i ShopTransaction
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 UpdateShopTransactionVerified = `-- name: UpdateShopTransactionVerified :exec
UPDATE shop_transactions
SET verified = $2,
approved_by = $3,
approver_name = $4,
updated_at = CURRENT_TIMESTAMP
WHERE id = $1
`
type UpdateShopTransactionVerifiedParams struct {
ID int64 `json:"id"`
Verified bool `json:"verified"`
ApprovedBy pgtype.Int8 `json:"approved_by"`
ApproverName pgtype.Text `json:"approver_name"`
}
func (q *Queries) UpdateShopTransactionVerified(ctx context.Context, arg UpdateShopTransactionVerifiedParams) error {
_, err := q.db.Exec(ctx, UpdateShopTransactionVerified,
arg.ID,
arg.Verified,
arg.ApprovedBy,
arg.ApproverName,
)
return err
}