Yimaru-BackEnd/gen/db/institutions.sql.go
Samuel Tariku e49ff366d5 feat: Implement wallet notification system and refactor related services
- Added new notification handling in the wallet service to notify admins when wallet balances are low or insufficient.
- Created a new file for wallet notifications and moved relevant functions from the wallet service to this new file.
- Updated the wallet service to publish wallet events including wallet type.
- Refactored the client code to improve readability and maintainability.
- Enhanced the bet handler to support pagination and status filtering for bets.
- Updated routes and handlers for user search functionality to improve clarity and organization.
- Modified cron job scheduling to comment out unused jobs for clarity.
- Updated the WebSocket broadcast to include wallet type in notifications.
- Adjusted the makefile to include Kafka in the docker-compose setup for local development.
2025-09-25 21:26:24 +03:00

302 lines
6.6 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.29.0
// source: institutions.sql
package dbgen
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const CountBanks = `-- name: CountBanks :one
SELECT COUNT(*)
FROM banks
WHERE (
country_id = $1
OR $1 IS NULL
)
AND (
is_active = $2
OR $2 IS NULL
)
AND (
name ILIKE '%' || $3 || '%'
OR code ILIKE '%' || $3 || '%'
OR $3 IS NULL
)
`
type CountBanksParams struct {
CountryID int32 `json:"country_id"`
IsActive int32 `json:"is_active"`
Column3 pgtype.Text `json:"column_3"`
}
func (q *Queries) CountBanks(ctx context.Context, arg CountBanksParams) (int64, error) {
row := q.db.QueryRow(ctx, CountBanks, arg.CountryID, arg.IsActive, arg.Column3)
var count int64
err := row.Scan(&count)
return count, err
}
const CreateBank = `-- name: CreateBank :one
INSERT INTO banks (
slug,
swift,
name,
acct_length,
country_id,
is_mobilemoney,
is_active,
is_rtgs,
active,
is_24hrs,
created_at,
updated_at,
currency,
bank_logo
)
VALUES (
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, $11, $12
)
RETURNING id, slug, swift, name, acct_length, country_id, is_mobilemoney, is_active, is_rtgs, active, is_24hrs, created_at, updated_at, currency, bank_logo
`
type CreateBankParams struct {
Slug string `json:"slug"`
Swift string `json:"swift"`
Name string `json:"name"`
AcctLength int32 `json:"acct_length"`
CountryID int32 `json:"country_id"`
IsMobilemoney pgtype.Int4 `json:"is_mobilemoney"`
IsActive int32 `json:"is_active"`
IsRtgs int32 `json:"is_rtgs"`
Active int32 `json:"active"`
Is24hrs pgtype.Int4 `json:"is_24hrs"`
Currency string `json:"currency"`
BankLogo pgtype.Text `json:"bank_logo"`
}
func (q *Queries) CreateBank(ctx context.Context, arg CreateBankParams) (Bank, error) {
row := q.db.QueryRow(ctx, CreateBank,
arg.Slug,
arg.Swift,
arg.Name,
arg.AcctLength,
arg.CountryID,
arg.IsMobilemoney,
arg.IsActive,
arg.IsRtgs,
arg.Active,
arg.Is24hrs,
arg.Currency,
arg.BankLogo,
)
var i Bank
err := row.Scan(
&i.ID,
&i.Slug,
&i.Swift,
&i.Name,
&i.AcctLength,
&i.CountryID,
&i.IsMobilemoney,
&i.IsActive,
&i.IsRtgs,
&i.Active,
&i.Is24hrs,
&i.CreatedAt,
&i.UpdatedAt,
&i.Currency,
&i.BankLogo,
)
return i, err
}
const DeleteBank = `-- name: DeleteBank :exec
DELETE FROM banks
WHERE id = $1
`
func (q *Queries) DeleteBank(ctx context.Context, id int64) error {
_, err := q.db.Exec(ctx, DeleteBank, id)
return err
}
const GetAllBanks = `-- name: GetAllBanks :many
SELECT id, slug, swift, name, acct_length, country_id, is_mobilemoney, is_active, is_rtgs, active, is_24hrs, created_at, updated_at, currency, bank_logo
FROM banks
WHERE (
country_id = $1
OR $1 IS NULL
)
AND (
is_active = $2
OR $2 IS NULL
)
AND (
name ILIKE '%' || $3 || '%'
OR $3 IS NULL
)
AND (
code ILIKE '%' || $3 || '%'
OR $3 IS NULL
)
ORDER BY name ASC
LIMIT $5 OFFSET $4
`
type GetAllBanksParams struct {
CountryID pgtype.Int4 `json:"country_id"`
IsActive pgtype.Int4 `json:"is_active"`
SearchTerm pgtype.Text `json:"search_term"`
Offset pgtype.Int4 `json:"offset"`
Limit pgtype.Int4 `json:"limit"`
}
func (q *Queries) GetAllBanks(ctx context.Context, arg GetAllBanksParams) ([]Bank, error) {
rows, err := q.db.Query(ctx, GetAllBanks,
arg.CountryID,
arg.IsActive,
arg.SearchTerm,
arg.Offset,
arg.Limit,
)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Bank
for rows.Next() {
var i Bank
if err := rows.Scan(
&i.ID,
&i.Slug,
&i.Swift,
&i.Name,
&i.AcctLength,
&i.CountryID,
&i.IsMobilemoney,
&i.IsActive,
&i.IsRtgs,
&i.Active,
&i.Is24hrs,
&i.CreatedAt,
&i.UpdatedAt,
&i.Currency,
&i.BankLogo,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const GetBankByID = `-- name: GetBankByID :one
SELECT id, slug, swift, name, acct_length, country_id, is_mobilemoney, is_active, is_rtgs, active, is_24hrs, created_at, updated_at, currency, bank_logo
FROM banks
WHERE id = $1
`
func (q *Queries) GetBankByID(ctx context.Context, id int64) (Bank, error) {
row := q.db.QueryRow(ctx, GetBankByID, id)
var i Bank
err := row.Scan(
&i.ID,
&i.Slug,
&i.Swift,
&i.Name,
&i.AcctLength,
&i.CountryID,
&i.IsMobilemoney,
&i.IsActive,
&i.IsRtgs,
&i.Active,
&i.Is24hrs,
&i.CreatedAt,
&i.UpdatedAt,
&i.Currency,
&i.BankLogo,
)
return i, err
}
const UpdateBank = `-- name: UpdateBank :one
UPDATE banks
SET slug = COALESCE($2, slug),
swift = COALESCE($3, swift),
name = COALESCE($4, name),
acct_length = COALESCE($5, acct_length),
country_id = COALESCE($6, country_id),
is_mobilemoney = COALESCE($7, is_mobilemoney),
is_active = COALESCE($8, is_active),
is_rtgs = COALESCE($9, is_rtgs),
active = COALESCE($10, active),
is_24hrs = COALESCE($11, is_24hrs),
updated_at = CURRENT_TIMESTAMP,
currency = COALESCE($12, currency),
bank_logo = COALESCE($13, bank_logo)
WHERE id = $1
RETURNING id, slug, swift, name, acct_length, country_id, is_mobilemoney, is_active, is_rtgs, active, is_24hrs, created_at, updated_at, currency, bank_logo
`
type UpdateBankParams struct {
ID int64 `json:"id"`
Slug pgtype.Text `json:"slug"`
Swift pgtype.Text `json:"swift"`
Name pgtype.Text `json:"name"`
AcctLength pgtype.Int4 `json:"acct_length"`
CountryID pgtype.Int4 `json:"country_id"`
IsMobilemoney pgtype.Int4 `json:"is_mobilemoney"`
IsActive pgtype.Int4 `json:"is_active"`
IsRtgs pgtype.Int4 `json:"is_rtgs"`
Active pgtype.Int4 `json:"active"`
Is24hrs pgtype.Int4 `json:"is_24hrs"`
Currency pgtype.Text `json:"currency"`
BankLogo pgtype.Text `json:"bank_logo"`
}
func (q *Queries) UpdateBank(ctx context.Context, arg UpdateBankParams) (Bank, error) {
row := q.db.QueryRow(ctx, UpdateBank,
arg.ID,
arg.Slug,
arg.Swift,
arg.Name,
arg.AcctLength,
arg.CountryID,
arg.IsMobilemoney,
arg.IsActive,
arg.IsRtgs,
arg.Active,
arg.Is24hrs,
arg.Currency,
arg.BankLogo,
)
var i Bank
err := row.Scan(
&i.ID,
&i.Slug,
&i.Swift,
&i.Name,
&i.AcctLength,
&i.CountryID,
&i.IsMobilemoney,
&i.IsActive,
&i.IsRtgs,
&i.Active,
&i.Is24hrs,
&i.CreatedAt,
&i.UpdatedAt,
&i.Currency,
&i.BankLogo,
)
return i, err
}