// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.29.0 // source: wallet.sql package dbgen import ( "context" "github.com/jackc/pgx/v5/pgtype" ) const CreateCustomerWallet = `-- name: CreateCustomerWallet :one INSERT INTO customer_wallets ( customer_id, regular_wallet_id, static_wallet_id ) VALUES ($1, $2, $3) RETURNING id, customer_id, regular_wallet_id, static_wallet_id, created_at, updated_at ` type CreateCustomerWalletParams struct { CustomerID int64 `json:"customer_id"` RegularWalletID int64 `json:"regular_wallet_id"` StaticWalletID int64 `json:"static_wallet_id"` } func (q *Queries) CreateCustomerWallet(ctx context.Context, arg CreateCustomerWalletParams) (CustomerWallet, error) { row := q.db.QueryRow(ctx, CreateCustomerWallet, arg.CustomerID, arg.RegularWalletID, arg.StaticWalletID) var i CustomerWallet err := row.Scan( &i.ID, &i.CustomerID, &i.RegularWalletID, &i.StaticWalletID, &i.CreatedAt, &i.UpdatedAt, ) return i, err } const CreateWallet = `-- name: CreateWallet :one INSERT INTO wallets ( is_withdraw, is_bettable, is_transferable, user_id ) VALUES ($1, $2, $3, $4) RETURNING id, balance, is_withdraw, is_bettable, is_transferable, user_id, is_active, created_at, updated_at, currency, bonus_balance, cash_balance ` type CreateWalletParams struct { IsWithdraw bool `json:"is_withdraw"` IsBettable bool `json:"is_bettable"` IsTransferable bool `json:"is_transferable"` UserID int64 `json:"user_id"` } func (q *Queries) CreateWallet(ctx context.Context, arg CreateWalletParams) (Wallet, error) { row := q.db.QueryRow(ctx, CreateWallet, arg.IsWithdraw, arg.IsBettable, arg.IsTransferable, arg.UserID, ) var i Wallet err := row.Scan( &i.ID, &i.Balance, &i.IsWithdraw, &i.IsBettable, &i.IsTransferable, &i.UserID, &i.IsActive, &i.CreatedAt, &i.UpdatedAt, &i.Currency, &i.BonusBalance, &i.CashBalance, ) return i, err } const GetAllBranchWallets = `-- name: GetAllBranchWallets :many SELECT wallets.id, wallets.balance, wallets.is_active, wallets.updated_at, wallets.created_at, branches.name, branches.location, branches.branch_manager_id, branches.company_id, branches.is_self_owned FROM branches JOIN wallets ON branches.wallet_id = wallets.id ` type GetAllBranchWalletsRow struct { ID int64 `json:"id"` Balance int64 `json:"balance"` IsActive bool `json:"is_active"` UpdatedAt pgtype.Timestamp `json:"updated_at"` CreatedAt pgtype.Timestamp `json:"created_at"` Name string `json:"name"` Location string `json:"location"` BranchManagerID int64 `json:"branch_manager_id"` CompanyID int64 `json:"company_id"` IsSelfOwned bool `json:"is_self_owned"` } func (q *Queries) GetAllBranchWallets(ctx context.Context) ([]GetAllBranchWalletsRow, error) { rows, err := q.db.Query(ctx, GetAllBranchWallets) if err != nil { return nil, err } defer rows.Close() var items []GetAllBranchWalletsRow for rows.Next() { var i GetAllBranchWalletsRow if err := rows.Scan( &i.ID, &i.Balance, &i.IsActive, &i.UpdatedAt, &i.CreatedAt, &i.Name, &i.Location, &i.BranchManagerID, &i.CompanyID, &i.IsSelfOwned, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const GetAllCustomerWallet = `-- name: GetAllCustomerWallet :many SELECT id, customer_id, regular_id, regular_balance, static_id, static_balance, regular_is_active, static_is_active, regular_updated_at, static_updated_at, created_at, first_name, last_name, phone_number FROM customer_wallet_details ` func (q *Queries) GetAllCustomerWallet(ctx context.Context) ([]CustomerWalletDetail, error) { rows, err := q.db.Query(ctx, GetAllCustomerWallet) if err != nil { return nil, err } defer rows.Close() var items []CustomerWalletDetail for rows.Next() { var i CustomerWalletDetail if err := rows.Scan( &i.ID, &i.CustomerID, &i.RegularID, &i.RegularBalance, &i.StaticID, &i.StaticBalance, &i.RegularIsActive, &i.StaticIsActive, &i.RegularUpdatedAt, &i.StaticUpdatedAt, &i.CreatedAt, &i.FirstName, &i.LastName, &i.PhoneNumber, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const GetAllWallets = `-- name: GetAllWallets :many SELECT id, balance, is_withdraw, is_bettable, is_transferable, user_id, is_active, created_at, updated_at, currency, bonus_balance, cash_balance FROM wallets ` func (q *Queries) GetAllWallets(ctx context.Context) ([]Wallet, error) { rows, err := q.db.Query(ctx, GetAllWallets) if err != nil { return nil, err } defer rows.Close() var items []Wallet for rows.Next() { var i Wallet if err := rows.Scan( &i.ID, &i.Balance, &i.IsWithdraw, &i.IsBettable, &i.IsTransferable, &i.UserID, &i.IsActive, &i.CreatedAt, &i.UpdatedAt, &i.Currency, &i.BonusBalance, &i.CashBalance, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const GetBranchByWalletID = `-- name: GetBranchByWalletID :one SELECT id, name, location, is_active, wallet_id, branch_manager_id, company_id, is_self_owned, created_at, updated_at FROM branches WHERE wallet_id = $1 LIMIT 1 ` type GetBranchByWalletIDRow struct { ID int64 `json:"id"` Name string `json:"name"` Location string `json:"location"` IsActive bool `json:"is_active"` WalletID int64 `json:"wallet_id"` BranchManagerID int64 `json:"branch_manager_id"` CompanyID int64 `json:"company_id"` IsSelfOwned bool `json:"is_self_owned"` CreatedAt pgtype.Timestamp `json:"created_at"` UpdatedAt pgtype.Timestamp `json:"updated_at"` } func (q *Queries) GetBranchByWalletID(ctx context.Context, walletID int64) (GetBranchByWalletIDRow, error) { row := q.db.QueryRow(ctx, GetBranchByWalletID, walletID) var i GetBranchByWalletIDRow err := row.Scan( &i.ID, &i.Name, &i.Location, &i.IsActive, &i.WalletID, &i.BranchManagerID, &i.CompanyID, &i.IsSelfOwned, &i.CreatedAt, &i.UpdatedAt, ) return i, err } const GetCompanyByWalletID = `-- name: GetCompanyByWalletID :one SELECT id, name, admin_id, wallet_id FROM companies WHERE wallet_id = $1 LIMIT 1 ` type GetCompanyByWalletIDRow struct { ID int64 `json:"id"` Name string `json:"name"` AdminID int64 `json:"admin_id"` WalletID int64 `json:"wallet_id"` } func (q *Queries) GetCompanyByWalletID(ctx context.Context, walletID int64) (GetCompanyByWalletIDRow, error) { row := q.db.QueryRow(ctx, GetCompanyByWalletID, walletID) var i GetCompanyByWalletIDRow err := row.Scan( &i.ID, &i.Name, &i.AdminID, &i.WalletID, ) return i, err } const GetCustomerWallet = `-- name: GetCustomerWallet :one SELECT id, customer_id, regular_id, regular_balance, static_id, static_balance, regular_is_active, static_is_active, regular_updated_at, static_updated_at, created_at, first_name, last_name, phone_number FROM customer_wallet_details WHERE customer_id = $1 ` func (q *Queries) GetCustomerWallet(ctx context.Context, customerID int64) (CustomerWalletDetail, error) { row := q.db.QueryRow(ctx, GetCustomerWallet, customerID) var i CustomerWalletDetail err := row.Scan( &i.ID, &i.CustomerID, &i.RegularID, &i.RegularBalance, &i.StaticID, &i.StaticBalance, &i.RegularIsActive, &i.StaticIsActive, &i.RegularUpdatedAt, &i.StaticUpdatedAt, &i.CreatedAt, &i.FirstName, &i.LastName, &i.PhoneNumber, ) return i, err } const GetWalletByID = `-- name: GetWalletByID :one SELECT id, balance, is_withdraw, is_bettable, is_transferable, user_id, is_active, created_at, updated_at, currency, bonus_balance, cash_balance FROM wallets WHERE id = $1 ` func (q *Queries) GetWalletByID(ctx context.Context, id int64) (Wallet, error) { row := q.db.QueryRow(ctx, GetWalletByID, id) var i Wallet err := row.Scan( &i.ID, &i.Balance, &i.IsWithdraw, &i.IsBettable, &i.IsTransferable, &i.UserID, &i.IsActive, &i.CreatedAt, &i.UpdatedAt, &i.Currency, &i.BonusBalance, &i.CashBalance, ) return i, err } const GetWalletByUserID = `-- name: GetWalletByUserID :many SELECT id, balance, is_withdraw, is_bettable, is_transferable, user_id, is_active, created_at, updated_at, currency, bonus_balance, cash_balance FROM wallets WHERE user_id = $1 ` func (q *Queries) GetWalletByUserID(ctx context.Context, userID int64) ([]Wallet, error) { rows, err := q.db.Query(ctx, GetWalletByUserID, userID) if err != nil { return nil, err } defer rows.Close() var items []Wallet for rows.Next() { var i Wallet if err := rows.Scan( &i.ID, &i.Balance, &i.IsWithdraw, &i.IsBettable, &i.IsTransferable, &i.UserID, &i.IsActive, &i.CreatedAt, &i.UpdatedAt, &i.Currency, &i.BonusBalance, &i.CashBalance, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const UpdateBalance = `-- name: UpdateBalance :exec UPDATE wallets SET balance = $1, updated_at = CURRENT_TIMESTAMP WHERE id = $2 ` type UpdateBalanceParams struct { Balance int64 `json:"balance"` ID int64 `json:"id"` } func (q *Queries) UpdateBalance(ctx context.Context, arg UpdateBalanceParams) error { _, err := q.db.Exec(ctx, UpdateBalance, arg.Balance, arg.ID) return err } const UpdateWalletActive = `-- name: UpdateWalletActive :exec UPDATE wallets SET is_active = $1, updated_at = CURRENT_TIMESTAMP WHERE id = $2 ` type UpdateWalletActiveParams struct { IsActive bool `json:"is_active"` ID int64 `json:"id"` } func (q *Queries) UpdateWalletActive(ctx context.Context, arg UpdateWalletActiveParams) error { _, err := q.db.Exec(ctx, UpdateWalletActive, arg.IsActive, arg.ID) return err }