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

190 lines
4.0 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.29.0
// source: result.sql
package dbgen
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const CreateResult = `-- name: CreateResult :one
INSERT INTO results (
bet_outcome_id,
event_id,
odd_id,
market_id,
status,
score,
created_at,
updated_at
) VALUES (
$1,
$2,
$3,
$4,
$5,
$6,
CURRENT_TIMESTAMP,
CURRENT_TIMESTAMP
) RETURNING id, bet_outcome_id, event_id, odd_id, market_id, status, score, full_time_score, half_time_score, ss, created_at, updated_at
`
type CreateResultParams struct {
BetOutcomeID int64 `json:"bet_outcome_id"`
EventID int64 `json:"event_id"`
OddID int64 `json:"odd_id"`
MarketID int64 `json:"market_id"`
Status int32 `json:"status"`
Score pgtype.Text `json:"score"`
}
func (q *Queries) CreateResult(ctx context.Context, arg CreateResultParams) (Result, error) {
row := q.db.QueryRow(ctx, CreateResult,
arg.BetOutcomeID,
arg.EventID,
arg.OddID,
arg.MarketID,
arg.Status,
arg.Score,
)
var i Result
err := row.Scan(
&i.ID,
&i.BetOutcomeID,
&i.EventID,
&i.OddID,
&i.MarketID,
&i.Status,
&i.Score,
&i.FullTimeScore,
&i.HalfTimeScore,
&i.Ss,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const GetPendingBetOutcomes = `-- name: GetPendingBetOutcomes :many
SELECT id, bet_id, sport_id, event_id, odd_id, home_team_name, away_team_name, market_id, market_name, odd, odd_name, odd_header, odd_handicap, status, expires FROM bet_outcomes WHERE status = 0 AND expires <= CURRENT_TIMESTAMP
`
func (q *Queries) GetPendingBetOutcomes(ctx context.Context) ([]BetOutcome, error) {
rows, err := q.db.Query(ctx, GetPendingBetOutcomes)
if err != nil {
return nil, err
}
defer rows.Close()
var items []BetOutcome
for rows.Next() {
var i BetOutcome
if err := rows.Scan(
&i.ID,
&i.BetID,
&i.SportID,
&i.EventID,
&i.OddID,
&i.HomeTeamName,
&i.AwayTeamName,
&i.MarketID,
&i.MarketName,
&i.Odd,
&i.OddName,
&i.OddHeader,
&i.OddHandicap,
&i.Status,
&i.Expires,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const GetResultByBetOutcomeID = `-- name: GetResultByBetOutcomeID :one
SELECT id, bet_outcome_id, event_id, odd_id, market_id, status, score, full_time_score, half_time_score, ss, created_at, updated_at FROM results WHERE bet_outcome_id = $1
`
func (q *Queries) GetResultByBetOutcomeID(ctx context.Context, betOutcomeID int64) (Result, error) {
row := q.db.QueryRow(ctx, GetResultByBetOutcomeID, betOutcomeID)
var i Result
err := row.Scan(
&i.ID,
&i.BetOutcomeID,
&i.EventID,
&i.OddID,
&i.MarketID,
&i.Status,
&i.Score,
&i.FullTimeScore,
&i.HalfTimeScore,
&i.Ss,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const InsertResult = `-- name: InsertResult :exec
INSERT INTO results (
bet_outcome_id,
event_id,
odd_id,
market_id,
status,
score,
full_time_score,
half_time_score,
ss,
created_at,
updated_at
) VALUES (
$1,
$2,
$3,
$4,
$5,
$6,
$7,
$8,
$9,
CURRENT_TIMESTAMP,
CURRENT_TIMESTAMP
)
`
type InsertResultParams struct {
BetOutcomeID int64 `json:"bet_outcome_id"`
EventID int64 `json:"event_id"`
OddID int64 `json:"odd_id"`
MarketID int64 `json:"market_id"`
Status int32 `json:"status"`
Score pgtype.Text `json:"score"`
FullTimeScore pgtype.Text `json:"full_time_score"`
HalfTimeScore pgtype.Text `json:"half_time_score"`
Ss pgtype.Text `json:"ss"`
}
func (q *Queries) InsertResult(ctx context.Context, arg InsertResultParams) error {
_, err := q.db.Exec(ctx, InsertResult,
arg.BetOutcomeID,
arg.EventID,
arg.OddID,
arg.MarketID,
arg.Status,
arg.Score,
arg.FullTimeScore,
arg.HalfTimeScore,
arg.Ss,
)
return err
}