132 lines
3.2 KiB
Go
132 lines
3.2 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.28.0
|
|
// source: monitor.sql
|
|
|
|
package dbgen
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const CountThresholdNotifications = `-- name: CountThresholdNotifications :one
|
|
SELECT COUNT(*)
|
|
FROM wallet_threshold_notifications
|
|
WHERE company_id = $1 AND threshold = $2
|
|
`
|
|
|
|
type CountThresholdNotificationsParams struct {
|
|
CompanyID int64 `json:"company_id"`
|
|
Threshold float64 `json:"threshold"`
|
|
}
|
|
|
|
func (q *Queries) CountThresholdNotifications(ctx context.Context, arg CountThresholdNotificationsParams) (int64, error) {
|
|
row := q.db.QueryRow(ctx, CountThresholdNotifications, arg.CompanyID, arg.Threshold)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const CreateThresholdNotification = `-- name: CreateThresholdNotification :exec
|
|
INSERT INTO wallet_threshold_notifications (company_id, threshold)
|
|
VALUES ($1, $2)
|
|
`
|
|
|
|
type CreateThresholdNotificationParams struct {
|
|
CompanyID int64 `json:"company_id"`
|
|
Threshold float64 `json:"threshold"`
|
|
}
|
|
|
|
func (q *Queries) CreateThresholdNotification(ctx context.Context, arg CreateThresholdNotificationParams) error {
|
|
_, err := q.db.Exec(ctx, CreateThresholdNotification, arg.CompanyID, arg.Threshold)
|
|
return err
|
|
}
|
|
|
|
const GetAllCompaniesBranch = `-- name: GetAllCompaniesBranch :many
|
|
SELECT id, name, wallet_id, admin_id
|
|
FROM companies
|
|
`
|
|
|
|
type GetAllCompaniesBranchRow struct {
|
|
ID int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
WalletID int64 `json:"wallet_id"`
|
|
AdminID int64 `json:"admin_id"`
|
|
}
|
|
|
|
func (q *Queries) GetAllCompaniesBranch(ctx context.Context) ([]GetAllCompaniesBranchRow, error) {
|
|
rows, err := q.db.Query(ctx, GetAllCompaniesBranch)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []GetAllCompaniesBranchRow
|
|
for rows.Next() {
|
|
var i GetAllCompaniesBranchRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.WalletID,
|
|
&i.AdminID,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const GetBranchesByCompanyID = `-- name: GetBranchesByCompanyID :many
|
|
SELECT
|
|
id,
|
|
name,
|
|
location,
|
|
wallet_id,
|
|
branch_manager_id,
|
|
company_id,
|
|
is_self_owned
|
|
FROM branches
|
|
WHERE company_id = $1
|
|
`
|
|
|
|
type GetBranchesByCompanyIDRow struct {
|
|
ID int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
Location string `json:"location"`
|
|
WalletID int64 `json:"wallet_id"`
|
|
BranchManagerID int64 `json:"branch_manager_id"`
|
|
CompanyID int64 `json:"company_id"`
|
|
IsSelfOwned bool `json:"is_self_owned"`
|
|
}
|
|
|
|
func (q *Queries) GetBranchesByCompanyID(ctx context.Context, companyID int64) ([]GetBranchesByCompanyIDRow, error) {
|
|
rows, err := q.db.Query(ctx, GetBranchesByCompanyID, companyID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []GetBranchesByCompanyIDRow
|
|
for rows.Next() {
|
|
var i GetBranchesByCompanyIDRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.Location,
|
|
&i.WalletID,
|
|
&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
|
|
}
|