152 lines
4.6 KiB
Go
152 lines
4.6 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.25.0
|
|
// source: competition.sql
|
|
|
|
package model
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const createOrUpdateCompetition = `-- name: CreateOrUpdateCompetition :exec
|
|
INSERT INTO competitions (
|
|
slug,
|
|
display_name,
|
|
country_slug,
|
|
competition_format,
|
|
competition_type,
|
|
picture_url,
|
|
logo_url
|
|
)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7) ON CONFLICT (slug)
|
|
DO
|
|
UPDATE
|
|
SET display_name = EXCLUDED.display_name,
|
|
competition_format = EXCLUDED.competition_format,
|
|
competition_type = EXCLUDED.competition_type,
|
|
picture_url = EXCLUDED.picture_url,
|
|
logo_url = EXCLUDED.logo_url,
|
|
country_slug = EXCLUDED.country_slug
|
|
`
|
|
|
|
type CreateOrUpdateCompetitionParams struct {
|
|
Slug string
|
|
DisplayName string
|
|
CountrySlug string
|
|
CompetitionFormat string
|
|
CompetitionType string
|
|
PictureUrl string
|
|
LogoUrl string
|
|
}
|
|
|
|
// Active: 1709890109198@@192.168.1.250@5436@sorare
|
|
func (q *Queries) CreateOrUpdateCompetition(ctx context.Context, arg CreateOrUpdateCompetitionParams) error {
|
|
_, err := q.db.Exec(ctx, createOrUpdateCompetition,
|
|
arg.Slug,
|
|
arg.DisplayName,
|
|
arg.CountrySlug,
|
|
arg.CompetitionFormat,
|
|
arg.CompetitionType,
|
|
arg.PictureUrl,
|
|
arg.LogoUrl,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const getAllCompetitions = `-- name: GetAllCompetitions :many
|
|
SELECT competitions.slug, competitions.display_name, competitions.country_slug, competitions.competition_format, competitions.competition_type, competitions.picture_url, competitions.logo_url, competitions.zone_id,
|
|
zones.id, zones.display_name,
|
|
countries.slug, countries.code, countries.display_name, countries.three_letter_code, countries.flag_flat_64_url, countries.flag_flat_32_url, countries.flag_round_64_url, countries.flag_round_32_url
|
|
FROM competitions
|
|
LEFT JOIN zones ON competitions.zone_id = zones.id
|
|
LEFT JOIN countries ON competitions.country_slug = countries.slug
|
|
`
|
|
|
|
type GetAllCompetitionsRow struct {
|
|
Competition Competition
|
|
Zone Zone
|
|
Country Country
|
|
}
|
|
|
|
func (q *Queries) GetAllCompetitions(ctx context.Context) ([]GetAllCompetitionsRow, error) {
|
|
rows, err := q.db.Query(ctx, getAllCompetitions)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []GetAllCompetitionsRow
|
|
for rows.Next() {
|
|
var i GetAllCompetitionsRow
|
|
if err := rows.Scan(
|
|
&i.Competition.Slug,
|
|
&i.Competition.DisplayName,
|
|
&i.Competition.CountrySlug,
|
|
&i.Competition.CompetitionFormat,
|
|
&i.Competition.CompetitionType,
|
|
&i.Competition.PictureUrl,
|
|
&i.Competition.LogoUrl,
|
|
&i.Competition.ZoneID,
|
|
&i.Zone.ID,
|
|
&i.Zone.DisplayName,
|
|
&i.Country.Slug,
|
|
&i.Country.Code,
|
|
&i.Country.DisplayName,
|
|
&i.Country.ThreeLetterCode,
|
|
&i.Country.FlagFlat64Url,
|
|
&i.Country.FlagFlat32Url,
|
|
&i.Country.FlagRound64Url,
|
|
&i.Country.FlagRound32Url,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const getCompetitionBySlug = `-- name: GetCompetitionBySlug :one
|
|
SELECT competitions.slug, competitions.display_name, competitions.country_slug, competitions.competition_format, competitions.competition_type, competitions.picture_url, competitions.logo_url, competitions.zone_id,
|
|
zones.id, zones.display_name,
|
|
countries.slug, countries.code, countries.display_name, countries.three_letter_code, countries.flag_flat_64_url, countries.flag_flat_32_url, countries.flag_round_64_url, countries.flag_round_32_url
|
|
FROM competitions
|
|
LEFT JOIN zones ON competitions.zone_id = zones.id
|
|
LEFT JOIN countries ON competitions.country_slug = countries.slug
|
|
WHERE competitions.slug = $1
|
|
`
|
|
|
|
type GetCompetitionBySlugRow struct {
|
|
Competition Competition
|
|
Zone Zone
|
|
Country Country
|
|
}
|
|
|
|
func (q *Queries) GetCompetitionBySlug(ctx context.Context, slug string) (GetCompetitionBySlugRow, error) {
|
|
row := q.db.QueryRow(ctx, getCompetitionBySlug, slug)
|
|
var i GetCompetitionBySlugRow
|
|
err := row.Scan(
|
|
&i.Competition.Slug,
|
|
&i.Competition.DisplayName,
|
|
&i.Competition.CountrySlug,
|
|
&i.Competition.CompetitionFormat,
|
|
&i.Competition.CompetitionType,
|
|
&i.Competition.PictureUrl,
|
|
&i.Competition.LogoUrl,
|
|
&i.Competition.ZoneID,
|
|
&i.Zone.ID,
|
|
&i.Zone.DisplayName,
|
|
&i.Country.Slug,
|
|
&i.Country.Code,
|
|
&i.Country.DisplayName,
|
|
&i.Country.ThreeLetterCode,
|
|
&i.Country.FlagFlat64Url,
|
|
&i.Country.FlagFlat32Url,
|
|
&i.Country.FlagRound64Url,
|
|
&i.Country.FlagRound32Url,
|
|
)
|
|
return i, err
|
|
}
|