owpengram-server/internal/store/postgres/sqlcgen/help.sql.go
2026-06-04 01:37:39 +08:00

159 lines
3.4 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
// source: help.sql
package sqlcgen
import (
"context"
)
const getAppConfig = `-- name: GetAppConfig :one
SELECT client, hash, config_json::text AS config_json
FROM app_configs
WHERE client = $1
`
type GetAppConfigRow struct {
Client string
Hash int32
ConfigJson string
}
func (q *Queries) GetAppConfig(ctx context.Context, client string) (GetAppConfigRow, error) {
row := q.db.QueryRow(ctx, getAppConfig, client)
var i GetAppConfigRow
err := row.Scan(&i.Client, &i.Hash, &i.ConfigJson)
return i, err
}
const listCountries = `-- name: ListCountries :many
SELECT
c.iso2,
c.default_name,
c.name,
c.hidden,
cc.country_code,
cc.prefixes,
cc.patterns
FROM countries c
JOIN country_codes cc ON cc.iso2 = c.iso2
ORDER BY c.order_index, c.iso2, cc.order_index, cc.country_code
`
type ListCountriesRow struct {
Iso2 string
DefaultName string
Name string
Hidden bool
CountryCode string
Prefixes []string
Patterns []string
}
func (q *Queries) ListCountries(ctx context.Context) ([]ListCountriesRow, error) {
rows, err := q.db.Query(ctx, listCountries)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ListCountriesRow
for rows.Next() {
var i ListCountriesRow
if err := rows.Scan(
&i.Iso2,
&i.DefaultName,
&i.Name,
&i.Hidden,
&i.CountryCode,
&i.Prefixes,
&i.Patterns,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const upsertAppConfig = `-- name: UpsertAppConfig :exec
INSERT INTO app_configs (client, hash, config_json)
VALUES ($1, $2, $3::jsonb)
ON CONFLICT (client) DO UPDATE SET
hash = EXCLUDED.hash,
config_json = EXCLUDED.config_json,
updated_at = now()
`
type UpsertAppConfigParams struct {
Client string
Hash int32
ConfigJson []byte
}
func (q *Queries) UpsertAppConfig(ctx context.Context, arg UpsertAppConfigParams) error {
_, err := q.db.Exec(ctx, upsertAppConfig, arg.Client, arg.Hash, arg.ConfigJson)
return err
}
const upsertCountry = `-- name: UpsertCountry :exec
INSERT INTO countries (iso2, default_name, name, hidden, order_index)
VALUES ($1, $2, $3, $4, $5)
ON CONFLICT (iso2) DO UPDATE SET
default_name = EXCLUDED.default_name,
name = EXCLUDED.name,
hidden = EXCLUDED.hidden,
order_index = EXCLUDED.order_index,
updated_at = now()
`
type UpsertCountryParams struct {
Iso2 string
DefaultName string
Name string
Hidden bool
OrderIndex int32
}
func (q *Queries) UpsertCountry(ctx context.Context, arg UpsertCountryParams) error {
_, err := q.db.Exec(ctx, upsertCountry,
arg.Iso2,
arg.DefaultName,
arg.Name,
arg.Hidden,
arg.OrderIndex,
)
return err
}
const upsertCountryCode = `-- name: UpsertCountryCode :exec
INSERT INTO country_codes (iso2, country_code, prefixes, patterns, order_index)
VALUES ($1, $2, $3, $4, $5)
ON CONFLICT (iso2, country_code) DO UPDATE SET
prefixes = EXCLUDED.prefixes,
patterns = EXCLUDED.patterns,
order_index = EXCLUDED.order_index
`
type UpsertCountryCodeParams struct {
Iso2 string
CountryCode string
Prefixes []string
Patterns []string
OrderIndex int32
}
func (q *Queries) UpsertCountryCode(ctx context.Context, arg UpsertCountryCodeParams) error {
_, err := q.db.Exec(ctx, upsertCountryCode,
arg.Iso2,
arg.CountryCode,
arg.Prefixes,
arg.Patterns,
arg.OrderIndex,
)
return err
}