143 lines
3.0 KiB
Go
143 lines
3.0 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.28.0
|
|
// source: bet.sql
|
|
|
|
package dbgen
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const CreateBet = `-- name: CreateBet :one
|
|
INSERT INTO bets (amount, total_odds, status, full_name, phone_number, branch_id, user_id, is_shop_bet)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
|
RETURNING id, amount, total_odds, status, full_name, phone_number, branch_id, user_id, cashed_out, created_at, updated_at, is_shop_bet
|
|
`
|
|
|
|
type CreateBetParams struct {
|
|
Amount int64
|
|
TotalOdds float32
|
|
Status int32
|
|
FullName string
|
|
PhoneNumber string
|
|
BranchID pgtype.Int8
|
|
UserID pgtype.Int8
|
|
IsShopBet bool
|
|
}
|
|
|
|
func (q *Queries) CreateBet(ctx context.Context, arg CreateBetParams) (Bet, error) {
|
|
row := q.db.QueryRow(ctx, CreateBet,
|
|
arg.Amount,
|
|
arg.TotalOdds,
|
|
arg.Status,
|
|
arg.FullName,
|
|
arg.PhoneNumber,
|
|
arg.BranchID,
|
|
arg.UserID,
|
|
arg.IsShopBet,
|
|
)
|
|
var i Bet
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Amount,
|
|
&i.TotalOdds,
|
|
&i.Status,
|
|
&i.FullName,
|
|
&i.PhoneNumber,
|
|
&i.BranchID,
|
|
&i.UserID,
|
|
&i.CashedOut,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.IsShopBet,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const DeleteBet = `-- name: DeleteBet :exec
|
|
DELETE FROM bets WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteBet(ctx context.Context, id int64) error {
|
|
_, err := q.db.Exec(ctx, DeleteBet, id)
|
|
return err
|
|
}
|
|
|
|
const GetAllBets = `-- name: GetAllBets :many
|
|
SELECT id, amount, total_odds, status, full_name, phone_number, branch_id, user_id, cashed_out, created_at, updated_at, is_shop_bet FROM bets
|
|
`
|
|
|
|
func (q *Queries) GetAllBets(ctx context.Context) ([]Bet, error) {
|
|
rows, err := q.db.Query(ctx, GetAllBets)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Bet
|
|
for rows.Next() {
|
|
var i Bet
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Amount,
|
|
&i.TotalOdds,
|
|
&i.Status,
|
|
&i.FullName,
|
|
&i.PhoneNumber,
|
|
&i.BranchID,
|
|
&i.UserID,
|
|
&i.CashedOut,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.IsShopBet,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const GetBetByID = `-- name: GetBetByID :one
|
|
SELECT id, amount, total_odds, status, full_name, phone_number, branch_id, user_id, cashed_out, created_at, updated_at, is_shop_bet FROM bets WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) GetBetByID(ctx context.Context, id int64) (Bet, error) {
|
|
row := q.db.QueryRow(ctx, GetBetByID, id)
|
|
var i Bet
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Amount,
|
|
&i.TotalOdds,
|
|
&i.Status,
|
|
&i.FullName,
|
|
&i.PhoneNumber,
|
|
&i.BranchID,
|
|
&i.UserID,
|
|
&i.CashedOut,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.IsShopBet,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const UpdateCashOut = `-- name: UpdateCashOut :exec
|
|
UPDATE bets SET cashed_out = $2, updated_at = CURRENT_TIMESTAMP WHERE id = $1
|
|
`
|
|
|
|
type UpdateCashOutParams struct {
|
|
ID int64
|
|
CashedOut pgtype.Bool
|
|
}
|
|
|
|
func (q *Queries) UpdateCashOut(ctx context.Context, arg UpdateCashOutParams) error {
|
|
_, err := q.db.Exec(ctx, UpdateCashOut, arg.ID, arg.CashedOut)
|
|
return err
|
|
}
|