phase 0.3
This commit is contained in:
commit
4a94bfc4e7
52 changed files with 11653 additions and 0 deletions
548
internal/db/admin_client.go
Normal file
548
internal/db/admin_client.go
Normal file
|
|
@ -0,0 +1,548 @@
|
|||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
// AdminClient provides raw-SQL operations for the admin TUI.
|
||||
type AdminClient struct {
|
||||
db *sql.DB
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
// NewAdminClient opens and pings a MySQL connection.
|
||||
func NewAdminClient(dsn string) (*AdminClient, error) {
|
||||
d, err := sql.Open("mysql", dsn)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("open db: %w", err)
|
||||
}
|
||||
d.SetMaxOpenConns(5)
|
||||
d.SetMaxIdleConns(3)
|
||||
d.SetConnMaxLifetime(5 * time.Minute)
|
||||
ctx := context.Background()
|
||||
if err := d.PingContext(ctx); err != nil {
|
||||
d.Close()
|
||||
return nil, fmt.Errorf("ping db: %w", err)
|
||||
}
|
||||
return &AdminClient{db: d, ctx: ctx}, nil
|
||||
}
|
||||
|
||||
func (c *AdminClient) Close() { c.db.Close() }
|
||||
|
||||
// ── Products ──────────────────────────────────────────────────────────────────
|
||||
|
||||
type AdminProduct struct {
|
||||
ID uint16
|
||||
Name string
|
||||
}
|
||||
|
||||
func (c *AdminClient) ListProducts() ([]AdminProduct, error) {
|
||||
rows, err := c.db.QueryContext(c.ctx, `SELECT id, name FROM products ORDER BY id`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var out []AdminProduct
|
||||
for rows.Next() {
|
||||
var p AdminProduct
|
||||
if err := rows.Scan(&p.ID, &p.Name); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out = append(out, p)
|
||||
}
|
||||
return out, rows.Err()
|
||||
}
|
||||
|
||||
func (c *AdminClient) AddProduct(name string) error {
|
||||
_, err := c.db.ExecContext(c.ctx, `INSERT INTO products (name) VALUES (?)`, name)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *AdminClient) DeleteProduct(id uint16) error {
|
||||
_, err := c.db.ExecContext(c.ctx, `DELETE FROM products WHERE id = ?`, id)
|
||||
return err
|
||||
}
|
||||
|
||||
// ── Countries ─────────────────────────────────────────────────────────────────
|
||||
|
||||
type AdminCountry struct {
|
||||
ID uint16
|
||||
Name string
|
||||
Continent string
|
||||
P1, P2, P3 uint16
|
||||
}
|
||||
|
||||
func (c *AdminClient) ListCountries() ([]AdminCountry, error) {
|
||||
rows, err := c.db.QueryContext(c.ctx,
|
||||
`SELECT id, name, continent, produce_1_id, produce_2_id, produce_3_id FROM countries ORDER BY id`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var out []AdminCountry
|
||||
for rows.Next() {
|
||||
var co AdminCountry
|
||||
if err := rows.Scan(&co.ID, &co.Name, &co.Continent, &co.P1, &co.P2, &co.P3); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out = append(out, co)
|
||||
}
|
||||
return out, rows.Err()
|
||||
}
|
||||
|
||||
func (c *AdminClient) AddCountry(name, continent string, p1, p2, p3 uint16) error {
|
||||
_, err := c.db.ExecContext(c.ctx,
|
||||
`INSERT INTO countries (name,continent,produce_1_id,produce_2_id,produce_3_id) VALUES (?,?,?,?,?)`,
|
||||
name, continent, p1, p2, p3)
|
||||
return err
|
||||
}
|
||||
|
||||
// ── Factions ──────────────────────────────────────────────────────────────────
|
||||
|
||||
type AdminFaction struct {
|
||||
ID uint32
|
||||
Name string
|
||||
Continent string
|
||||
Leader string
|
||||
Background string
|
||||
UserID int32
|
||||
CentralAirportID uint32
|
||||
}
|
||||
|
||||
func (c *AdminClient) ListFactions() ([]AdminFaction, error) {
|
||||
rows, err := c.db.QueryContext(c.ctx,
|
||||
`SELECT id, name, continent, leader_name, COALESCE(background,''), user_id, central_airport_id
|
||||
FROM factions ORDER BY continent`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var out []AdminFaction
|
||||
for rows.Next() {
|
||||
var f AdminFaction
|
||||
if err := rows.Scan(&f.ID, &f.Name, &f.Continent, &f.Leader, &f.Background,
|
||||
&f.UserID, &f.CentralAirportID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out = append(out, f)
|
||||
}
|
||||
return out, rows.Err()
|
||||
}
|
||||
|
||||
func (c *AdminClient) AddFaction(name, continent, leader, background string, userID int32, centralAirportID uint32) error {
|
||||
_, err := c.db.ExecContext(c.ctx,
|
||||
`INSERT INTO factions (name, continent, leader_name, background, user_id, central_airport_id)
|
||||
VALUES (?,?,?,?,?,?)`,
|
||||
name, continent, leader, background, userID, centralAirportID)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *AdminClient) UpdateFaction(id uint32, name, continent, leader, background string, userID int32, centralAirportID uint32) error {
|
||||
_, err := c.db.ExecContext(c.ctx,
|
||||
`UPDATE factions SET name=?, continent=?, leader_name=?, background=?, user_id=?, central_airport_id=?
|
||||
WHERE id=?`,
|
||||
name, continent, leader, background, userID, centralAirportID, id)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *AdminClient) DeleteFaction(id uint32) error {
|
||||
_, err := c.db.ExecContext(c.ctx, `DELETE FROM factions WHERE id = ?`, id)
|
||||
return err
|
||||
}
|
||||
|
||||
// ── Buildings ─────────────────────────────────────────────────────────────────
|
||||
|
||||
type AdminBuilding struct {
|
||||
ID uint32
|
||||
Name string
|
||||
MinLevel uint32
|
||||
Cost uint32
|
||||
BuildingType string
|
||||
Details string
|
||||
// raw values used by the edit form
|
||||
Capacity int
|
||||
StorageType string
|
||||
StorageSubtype string
|
||||
OperationType string
|
||||
OperationSize string
|
||||
PassiveType string
|
||||
PassiveRate int
|
||||
}
|
||||
|
||||
func (c *AdminClient) ListBuildings() ([]AdminBuilding, error) {
|
||||
rows, err := c.db.QueryContext(c.ctx, `
|
||||
SELECT id, name, min_level, construction_cost_cash, building_type,
|
||||
COALESCE(storage_type,''), COALESCE(operation_type,''), COALESCE(passive_type,''),
|
||||
COALESCE(capacity,0), COALESCE(passive_rate,0), COALESCE(operation_size,''),
|
||||
COALESCE(storage_subtype,'')
|
||||
FROM buildings ORDER BY id`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var out []AdminBuilding
|
||||
for rows.Next() {
|
||||
var b AdminBuilding
|
||||
if err := rows.Scan(&b.ID, &b.Name, &b.MinLevel, &b.Cost, &b.BuildingType,
|
||||
&b.StorageType, &b.OperationType, &b.PassiveType,
|
||||
&b.Capacity, &b.PassiveRate, &b.OperationSize, &b.StorageSubtype); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch b.BuildingType {
|
||||
case "storage":
|
||||
b.Details = fmt.Sprintf("cap:%d type:%s", b.Capacity, b.StorageType)
|
||||
case "operation":
|
||||
b.Details = fmt.Sprintf("%s/%s", b.OperationType, b.OperationSize)
|
||||
case "passive":
|
||||
b.Details = fmt.Sprintf("%s +%d/s", b.PassiveType, b.PassiveRate)
|
||||
}
|
||||
out = append(out, b)
|
||||
}
|
||||
return out, rows.Err()
|
||||
}
|
||||
|
||||
type AddBuildingParams struct {
|
||||
Name string
|
||||
MinLevel uint32
|
||||
Cost uint32
|
||||
BuildingType string
|
||||
Capacity int
|
||||
StorageType string
|
||||
StorageSubtype string
|
||||
OperationType string
|
||||
OperationSize string
|
||||
PassiveType string
|
||||
PassiveRate int
|
||||
}
|
||||
|
||||
func (c *AdminClient) AddBuilding(p AddBuildingParams) error {
|
||||
switch p.BuildingType {
|
||||
case "storage":
|
||||
_, err := c.db.ExecContext(c.ctx,
|
||||
`INSERT INTO buildings (name,min_level,construction_cost_cash,building_type,capacity,storage_type,storage_subtype)
|
||||
VALUES (?,?,?,'storage',?,?,?)`,
|
||||
p.Name, p.MinLevel, p.Cost, p.Capacity, p.StorageType, p.StorageSubtype)
|
||||
return err
|
||||
case "operation":
|
||||
_, err := c.db.ExecContext(c.ctx,
|
||||
`INSERT INTO buildings (name,min_level,construction_cost_cash,building_type,operation_type,operation_size)
|
||||
VALUES (?,?,?,'operation',?,?)`,
|
||||
p.Name, p.MinLevel, p.Cost, p.OperationType, p.OperationSize)
|
||||
return err
|
||||
case "passive":
|
||||
_, err := c.db.ExecContext(c.ctx,
|
||||
`INSERT INTO buildings (name,min_level,construction_cost_cash,building_type,passive_type,passive_rate)
|
||||
VALUES (?,?,?,'passive',?,?)`,
|
||||
p.Name, p.MinLevel, p.Cost, p.PassiveType, p.PassiveRate)
|
||||
return err
|
||||
default:
|
||||
_, err := c.db.ExecContext(c.ctx,
|
||||
`INSERT INTO buildings (name,min_level,construction_cost_cash,building_type) VALUES (?,?,?,'none')`,
|
||||
p.Name, p.MinLevel, p.Cost)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func (c *AdminClient) DeleteBuilding(id uint32) error {
|
||||
_, err := c.db.ExecContext(c.ctx, `DELETE FROM buildings WHERE id = ?`, id)
|
||||
return err
|
||||
}
|
||||
|
||||
// ── Planes ────────────────────────────────────────────────────────────────────
|
||||
|
||||
type AdminPlane struct {
|
||||
ID uint32
|
||||
Name string
|
||||
Size string
|
||||
AircraftType string
|
||||
OperationType string
|
||||
MinLevel uint32
|
||||
TravelSec uint32
|
||||
FuelCost uint32
|
||||
BuyCost uint32
|
||||
// extra fields for edit form
|
||||
CashCost uint32
|
||||
MaxPassengers int
|
||||
XP uint32
|
||||
CashReward int
|
||||
CargoReward int
|
||||
BoardingTimeSec uint32
|
||||
FuelingTimeSec uint32
|
||||
}
|
||||
|
||||
func (c *AdminClient) ListPlanes() ([]AdminPlane, error) {
|
||||
rows, err := c.db.QueryContext(c.ctx, `
|
||||
SELECT id, name, aircraft_size, aircraft_type, operation_type, min_level,
|
||||
travel_time_inSeconds, operation_cost_fuel, buying_cost_cash,
|
||||
operation_cost_cash, COALESCE(max_passengers,0),
|
||||
completed_flight_experience,
|
||||
COALESCE(completed_flight_cash_reward,0),
|
||||
COALESCE(completed_flight_cargo_reward,0),
|
||||
boarding_time_seconds, fueling_time_seconds
|
||||
FROM planes ORDER BY id`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var out []AdminPlane
|
||||
for rows.Next() {
|
||||
var p AdminPlane
|
||||
if err := rows.Scan(&p.ID, &p.Name, &p.Size, &p.AircraftType, &p.OperationType,
|
||||
&p.MinLevel, &p.TravelSec, &p.FuelCost, &p.BuyCost,
|
||||
&p.CashCost, &p.MaxPassengers, &p.XP, &p.CashReward, &p.CargoReward,
|
||||
&p.BoardingTimeSec, &p.FuelingTimeSec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out = append(out, p)
|
||||
}
|
||||
return out, rows.Err()
|
||||
}
|
||||
|
||||
type AddPlaneParams struct {
|
||||
Name string
|
||||
Size string
|
||||
AircraftType string
|
||||
OperationType string
|
||||
MinLevel uint32
|
||||
FuelCost uint32
|
||||
CashCost uint32
|
||||
MaxPassengers int
|
||||
TravelSec uint32
|
||||
BuyCost uint32
|
||||
XP uint32
|
||||
CashReward int
|
||||
CargoReward int
|
||||
BoardingTimeSec int
|
||||
FuelingTimeSec int
|
||||
}
|
||||
|
||||
func (c *AdminClient) AddPlane(p AddPlaneParams) error {
|
||||
var maxPax, cashRew, cargoRew interface{}
|
||||
if p.MaxPassengers > 0 {
|
||||
maxPax = p.MaxPassengers
|
||||
}
|
||||
if p.CashReward > 0 {
|
||||
cashRew = p.CashReward
|
||||
}
|
||||
if p.CargoReward > 0 {
|
||||
cargoRew = p.CargoReward
|
||||
}
|
||||
_, err := c.db.ExecContext(c.ctx, `
|
||||
INSERT INTO planes
|
||||
(name,aircraft_size,operation_type,aircraft_type,min_level,operation_cost_fuel,
|
||||
operation_cost_cash,max_passengers,travel_time_inSeconds,buying_cost_cash,
|
||||
completed_flight_experience,completed_flight_cash_reward,completed_flight_cargo_reward,
|
||||
boarding_time_seconds,fueling_time_seconds)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
|
||||
p.Name, p.Size, p.OperationType, p.AircraftType, p.MinLevel,
|
||||
p.FuelCost, p.CashCost, maxPax, p.TravelSec, p.BuyCost, p.XP, cashRew, cargoRew,
|
||||
p.BoardingTimeSec, p.FuelingTimeSec)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *AdminClient) DeletePlane(id uint32) error {
|
||||
_, err := c.db.ExecContext(c.ctx, `DELETE FROM planes WHERE id = ?`, id)
|
||||
return err
|
||||
}
|
||||
|
||||
// ── Users ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
type AdminUser struct {
|
||||
ID int32
|
||||
Username string
|
||||
CreatedAt time.Time
|
||||
Deleted bool
|
||||
}
|
||||
|
||||
func (c *AdminClient) ListUsers() ([]AdminUser, error) {
|
||||
rows, err := c.db.QueryContext(c.ctx,
|
||||
`SELECT id, username, created_at, (deleted_at IS NOT NULL) FROM users WHERE is_npc = FALSE ORDER BY id`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var out []AdminUser
|
||||
for rows.Next() {
|
||||
var u AdminUser
|
||||
if err := rows.Scan(&u.ID, &u.Username, &u.CreatedAt, &u.Deleted); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out = append(out, u)
|
||||
}
|
||||
return out, rows.Err()
|
||||
}
|
||||
|
||||
func (c *AdminClient) CreateUserWithAirport(username, password, airportName string, countryID int) error {
|
||||
hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tx, err := c.db.BeginTx(c.ctx, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
res, err := tx.ExecContext(c.ctx,
|
||||
`INSERT INTO users (username, password_hash) VALUES (?, ?)`, username, string(hash))
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
userID, _ := res.LastInsertId()
|
||||
_, err = tx.ExecContext(c.ctx,
|
||||
`INSERT INTO airports (name, user_id, origin_country_id, cash) VALUES (?, ?, ?, 10000)`,
|
||||
airportName, userID, countryID)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
return tx.Commit()
|
||||
}
|
||||
|
||||
func (c *AdminClient) DeleteUser(username string) error {
|
||||
_, err := c.db.ExecContext(c.ctx,
|
||||
`UPDATE users SET deleted_at = CURRENT_TIMESTAMP WHERE username = ?`, username)
|
||||
return err
|
||||
}
|
||||
|
||||
// ── Airports ──────────────────────────────────────────────────────────────────
|
||||
|
||||
type AdminAirport struct {
|
||||
ID uint32
|
||||
Name string
|
||||
Username string
|
||||
Cash uint64
|
||||
Fuel uint32
|
||||
Level uint32
|
||||
MaxFuel uint32
|
||||
MaxPax uint32
|
||||
}
|
||||
|
||||
func (c *AdminClient) ListAirports() ([]AdminAirport, error) {
|
||||
rows, err := c.db.QueryContext(c.ctx, `
|
||||
SELECT a.id, a.name, u.username, a.cash, a.current_fuel, a.player_level,
|
||||
a.max_fuel_capacity, a.max_passenger_capacity
|
||||
FROM airports a JOIN users u ON a.user_id = u.id
|
||||
WHERE a.is_deleted = FALSE ORDER BY a.id`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var out []AdminAirport
|
||||
for rows.Next() {
|
||||
var a AdminAirport
|
||||
if err := rows.Scan(&a.ID, &a.Name, &a.Username, &a.Cash, &a.Fuel, &a.Level,
|
||||
&a.MaxFuel, &a.MaxPax); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out = append(out, a)
|
||||
}
|
||||
return out, rows.Err()
|
||||
}
|
||||
|
||||
func (c *AdminClient) GiveAirportCash(airportID uint32, amount uint64) error {
|
||||
_, err := c.db.ExecContext(c.ctx,
|
||||
`UPDATE airports SET cash = cash + ? WHERE id = ?`, amount, airportID)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *AdminClient) GiveAirportBuilding(airportID, buildingID uint32) error {
|
||||
_, err := c.db.ExecContext(c.ctx,
|
||||
`INSERT INTO airport_buildings (airport_id, building_id) VALUES (?, ?)`, airportID, buildingID)
|
||||
return err
|
||||
}
|
||||
|
||||
// ── Update methods ────────────────────────────────────────────────────────────
|
||||
|
||||
func (c *AdminClient) UpdateProduct(id uint16, name string) error {
|
||||
_, err := c.db.ExecContext(c.ctx, `UPDATE products SET name=? WHERE id=?`, name, id)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *AdminClient) UpdateCountry(id uint16, name, continent string, p1, p2, p3 uint16) error {
|
||||
_, err := c.db.ExecContext(c.ctx,
|
||||
`UPDATE countries SET name=?, continent=?, produce_1_id=?, produce_2_id=?, produce_3_id=? WHERE id=?`,
|
||||
name, continent, p1, p2, p3, id)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *AdminClient) UpdateBuilding(id uint32, p AddBuildingParams) error {
|
||||
var cap, passRate interface{}
|
||||
var storType, storSubtype, opType, opSize, passType interface{}
|
||||
if p.BuildingType == "storage" {
|
||||
cap = p.Capacity
|
||||
storType = p.StorageType
|
||||
storSubtype = p.StorageSubtype
|
||||
}
|
||||
if p.BuildingType == "operation" {
|
||||
opType = p.OperationType
|
||||
opSize = p.OperationSize
|
||||
}
|
||||
if p.BuildingType == "passive" {
|
||||
passType = p.PassiveType
|
||||
passRate = p.PassiveRate
|
||||
}
|
||||
_, err := c.db.ExecContext(c.ctx, `
|
||||
UPDATE buildings SET
|
||||
name=?, min_level=?, construction_cost_cash=?, building_type=?,
|
||||
capacity=?, storage_type=?, storage_subtype=?,
|
||||
operation_type=?, operation_size=?,
|
||||
passive_type=?, passive_rate=?
|
||||
WHERE id=?`,
|
||||
p.Name, p.MinLevel, p.Cost, p.BuildingType,
|
||||
cap, storType, storSubtype,
|
||||
opType, opSize,
|
||||
passType, passRate,
|
||||
id)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *AdminClient) UpdatePlane(id uint32, p AddPlaneParams) error {
|
||||
var maxPax, cashRew, cargoRew interface{}
|
||||
if p.MaxPassengers > 0 {
|
||||
maxPax = p.MaxPassengers
|
||||
}
|
||||
if p.CashReward > 0 {
|
||||
cashRew = p.CashReward
|
||||
}
|
||||
if p.CargoReward > 0 {
|
||||
cargoRew = p.CargoReward
|
||||
}
|
||||
_, err := c.db.ExecContext(c.ctx, `
|
||||
UPDATE planes SET
|
||||
name=?, aircraft_size=?, operation_type=?, aircraft_type=?, min_level=?,
|
||||
operation_cost_fuel=?, operation_cost_cash=?, max_passengers=?,
|
||||
travel_time_inSeconds=?, buying_cost_cash=?,
|
||||
completed_flight_experience=?, completed_flight_cash_reward=?,
|
||||
completed_flight_cargo_reward=?,
|
||||
boarding_time_seconds=?, fueling_time_seconds=?
|
||||
WHERE id=?`,
|
||||
p.Name, p.Size, p.OperationType, p.AircraftType, p.MinLevel,
|
||||
p.FuelCost, p.CashCost, maxPax, p.TravelSec, p.BuyCost,
|
||||
p.XP, cashRew, cargoRew,
|
||||
p.BoardingTimeSec, p.FuelingTimeSec, id)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *AdminClient) UpdateUserPassword(username, newPassword string) error {
|
||||
hash, err := bcrypt.GenerateFromPassword([]byte(newPassword), bcrypt.DefaultCost)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = c.db.ExecContext(c.ctx,
|
||||
`UPDATE users SET password_hash=? WHERE username=?`, string(hash), username)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *AdminClient) UpdateAirport(id uint32, cash uint64, level, maxFuel, maxPax uint32) error {
|
||||
_, err := c.db.ExecContext(c.ctx, `
|
||||
UPDATE airports SET cash=?, player_level=?, max_fuel_capacity=?, max_passenger_capacity=?
|
||||
WHERE id=?`,
|
||||
cash, level, maxFuel, maxPax, id)
|
||||
return err
|
||||
}
|
||||
1384
internal/db/client.go
Normal file
1384
internal/db/client.go
Normal file
File diff suppressed because it is too large
Load diff
31
internal/db/db.go
Normal file
31
internal/db/db.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
type DBTX interface {
|
||||
ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
|
||||
PrepareContext(context.Context, string) (*sql.Stmt, error)
|
||||
QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
|
||||
QueryRowContext(context.Context, string, ...interface{}) *sql.Row
|
||||
}
|
||||
|
||||
func New(db DBTX) *Queries {
|
||||
return &Queries{db: db}
|
||||
}
|
||||
|
||||
type Queries struct {
|
||||
db DBTX
|
||||
}
|
||||
|
||||
func (q *Queries) WithTx(tx *sql.Tx) *Queries {
|
||||
return &Queries{
|
||||
db: tx,
|
||||
}
|
||||
}
|
||||
704
internal/db/models.go
Normal file
704
internal/db/models.go
Normal file
|
|
@ -0,0 +1,704 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"database/sql/driver"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type BuildingsBuildingType string
|
||||
|
||||
const (
|
||||
BuildingsBuildingTypeNone BuildingsBuildingType = "none"
|
||||
BuildingsBuildingTypeStorage BuildingsBuildingType = "storage"
|
||||
BuildingsBuildingTypeSupport BuildingsBuildingType = "support"
|
||||
BuildingsBuildingTypeOperation BuildingsBuildingType = "operation"
|
||||
BuildingsBuildingTypePassive BuildingsBuildingType = "passive"
|
||||
BuildingsBuildingTypeShop BuildingsBuildingType = "shop"
|
||||
BuildingsBuildingTypeProduction BuildingsBuildingType = "production"
|
||||
)
|
||||
|
||||
func (e *BuildingsBuildingType) Scan(src interface{}) error {
|
||||
switch s := src.(type) {
|
||||
case []byte:
|
||||
*e = BuildingsBuildingType(s)
|
||||
case string:
|
||||
*e = BuildingsBuildingType(s)
|
||||
default:
|
||||
return fmt.Errorf("unsupported scan type for BuildingsBuildingType: %T", src)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type NullBuildingsBuildingType struct {
|
||||
BuildingsBuildingType BuildingsBuildingType `json:"buildings_building_type"`
|
||||
Valid bool `json:"valid"` // Valid is true if BuildingsBuildingType is not NULL
|
||||
}
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (ns *NullBuildingsBuildingType) Scan(value interface{}) error {
|
||||
if value == nil {
|
||||
ns.BuildingsBuildingType, ns.Valid = "", false
|
||||
return nil
|
||||
}
|
||||
ns.Valid = true
|
||||
return ns.BuildingsBuildingType.Scan(value)
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (ns NullBuildingsBuildingType) Value() (driver.Value, error) {
|
||||
if !ns.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
return string(ns.BuildingsBuildingType), nil
|
||||
}
|
||||
|
||||
type BuildingsOperationSize string
|
||||
|
||||
const (
|
||||
BuildingsOperationSizeSmall BuildingsOperationSize = "small"
|
||||
BuildingsOperationSizeMedium BuildingsOperationSize = "medium"
|
||||
BuildingsOperationSizeLarge BuildingsOperationSize = "large"
|
||||
BuildingsOperationSizeHuge BuildingsOperationSize = "huge"
|
||||
)
|
||||
|
||||
func (e *BuildingsOperationSize) Scan(src interface{}) error {
|
||||
switch s := src.(type) {
|
||||
case []byte:
|
||||
*e = BuildingsOperationSize(s)
|
||||
case string:
|
||||
*e = BuildingsOperationSize(s)
|
||||
default:
|
||||
return fmt.Errorf("unsupported scan type for BuildingsOperationSize: %T", src)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type NullBuildingsOperationSize struct {
|
||||
BuildingsOperationSize BuildingsOperationSize `json:"buildings_operation_size"`
|
||||
Valid bool `json:"valid"` // Valid is true if BuildingsOperationSize is not NULL
|
||||
}
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (ns *NullBuildingsOperationSize) Scan(value interface{}) error {
|
||||
if value == nil {
|
||||
ns.BuildingsOperationSize, ns.Valid = "", false
|
||||
return nil
|
||||
}
|
||||
ns.Valid = true
|
||||
return ns.BuildingsOperationSize.Scan(value)
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (ns NullBuildingsOperationSize) Value() (driver.Value, error) {
|
||||
if !ns.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
return string(ns.BuildingsOperationSize), nil
|
||||
}
|
||||
|
||||
type BuildingsOperationType string
|
||||
|
||||
const (
|
||||
BuildingsOperationTypeRunway BuildingsOperationType = "runway"
|
||||
BuildingsOperationTypeService BuildingsOperationType = "service"
|
||||
BuildingsOperationTypeProduction BuildingsOperationType = "production"
|
||||
)
|
||||
|
||||
func (e *BuildingsOperationType) Scan(src interface{}) error {
|
||||
switch s := src.(type) {
|
||||
case []byte:
|
||||
*e = BuildingsOperationType(s)
|
||||
case string:
|
||||
*e = BuildingsOperationType(s)
|
||||
default:
|
||||
return fmt.Errorf("unsupported scan type for BuildingsOperationType: %T", src)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type NullBuildingsOperationType struct {
|
||||
BuildingsOperationType BuildingsOperationType `json:"buildings_operation_type"`
|
||||
Valid bool `json:"valid"` // Valid is true if BuildingsOperationType is not NULL
|
||||
}
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (ns *NullBuildingsOperationType) Scan(value interface{}) error {
|
||||
if value == nil {
|
||||
ns.BuildingsOperationType, ns.Valid = "", false
|
||||
return nil
|
||||
}
|
||||
ns.Valid = true
|
||||
return ns.BuildingsOperationType.Scan(value)
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (ns NullBuildingsOperationType) Value() (driver.Value, error) {
|
||||
if !ns.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
return string(ns.BuildingsOperationType), nil
|
||||
}
|
||||
|
||||
type BuildingsPassiveType string
|
||||
|
||||
const (
|
||||
BuildingsPassiveTypePassengers BuildingsPassiveType = "passengers"
|
||||
BuildingsPassiveTypeFuel BuildingsPassiveType = "fuel"
|
||||
)
|
||||
|
||||
func (e *BuildingsPassiveType) Scan(src interface{}) error {
|
||||
switch s := src.(type) {
|
||||
case []byte:
|
||||
*e = BuildingsPassiveType(s)
|
||||
case string:
|
||||
*e = BuildingsPassiveType(s)
|
||||
default:
|
||||
return fmt.Errorf("unsupported scan type for BuildingsPassiveType: %T", src)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type NullBuildingsPassiveType struct {
|
||||
BuildingsPassiveType BuildingsPassiveType `json:"buildings_passive_type"`
|
||||
Valid bool `json:"valid"` // Valid is true if BuildingsPassiveType is not NULL
|
||||
}
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (ns *NullBuildingsPassiveType) Scan(value interface{}) error {
|
||||
if value == nil {
|
||||
ns.BuildingsPassiveType, ns.Valid = "", false
|
||||
return nil
|
||||
}
|
||||
ns.Valid = true
|
||||
return ns.BuildingsPassiveType.Scan(value)
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (ns NullBuildingsPassiveType) Value() (driver.Value, error) {
|
||||
if !ns.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
return string(ns.BuildingsPassiveType), nil
|
||||
}
|
||||
|
||||
type BuildingsStorageSubtype string
|
||||
|
||||
const (
|
||||
BuildingsStorageSubtypeNone BuildingsStorageSubtype = "none"
|
||||
BuildingsStorageSubtypeAirplane BuildingsStorageSubtype = "airplane"
|
||||
BuildingsStorageSubtypeHelicopter BuildingsStorageSubtype = "helicopter"
|
||||
BuildingsStorageSubtypeSeaplane BuildingsStorageSubtype = "seaplane"
|
||||
BuildingsStorageSubtypeSpaceship BuildingsStorageSubtype = "spaceship"
|
||||
)
|
||||
|
||||
func (e *BuildingsStorageSubtype) Scan(src interface{}) error {
|
||||
switch s := src.(type) {
|
||||
case []byte:
|
||||
*e = BuildingsStorageSubtype(s)
|
||||
case string:
|
||||
*e = BuildingsStorageSubtype(s)
|
||||
default:
|
||||
return fmt.Errorf("unsupported scan type for BuildingsStorageSubtype: %T", src)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type NullBuildingsStorageSubtype struct {
|
||||
BuildingsStorageSubtype BuildingsStorageSubtype `json:"buildings_storage_subtype"`
|
||||
Valid bool `json:"valid"` // Valid is true if BuildingsStorageSubtype is not NULL
|
||||
}
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (ns *NullBuildingsStorageSubtype) Scan(value interface{}) error {
|
||||
if value == nil {
|
||||
ns.BuildingsStorageSubtype, ns.Valid = "", false
|
||||
return nil
|
||||
}
|
||||
ns.Valid = true
|
||||
return ns.BuildingsStorageSubtype.Scan(value)
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (ns NullBuildingsStorageSubtype) Value() (driver.Value, error) {
|
||||
if !ns.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
return string(ns.BuildingsStorageSubtype), nil
|
||||
}
|
||||
|
||||
type BuildingsStorageType string
|
||||
|
||||
const (
|
||||
BuildingsStorageTypeFuel BuildingsStorageType = "fuel"
|
||||
BuildingsStorageTypePlane BuildingsStorageType = "plane"
|
||||
BuildingsStorageTypeProduct BuildingsStorageType = "product"
|
||||
)
|
||||
|
||||
func (e *BuildingsStorageType) Scan(src interface{}) error {
|
||||
switch s := src.(type) {
|
||||
case []byte:
|
||||
*e = BuildingsStorageType(s)
|
||||
case string:
|
||||
*e = BuildingsStorageType(s)
|
||||
default:
|
||||
return fmt.Errorf("unsupported scan type for BuildingsStorageType: %T", src)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type NullBuildingsStorageType struct {
|
||||
BuildingsStorageType BuildingsStorageType `json:"buildings_storage_type"`
|
||||
Valid bool `json:"valid"` // Valid is true if BuildingsStorageType is not NULL
|
||||
}
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (ns *NullBuildingsStorageType) Scan(value interface{}) error {
|
||||
if value == nil {
|
||||
ns.BuildingsStorageType, ns.Valid = "", false
|
||||
return nil
|
||||
}
|
||||
ns.Valid = true
|
||||
return ns.BuildingsStorageType.Scan(value)
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (ns NullBuildingsStorageType) Value() (driver.Value, error) {
|
||||
if !ns.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
return string(ns.BuildingsStorageType), nil
|
||||
}
|
||||
|
||||
type CountriesContinent string
|
||||
|
||||
const (
|
||||
CountriesContinentVoid CountriesContinent = "void"
|
||||
CountriesContinentAfrica CountriesContinent = "Africa"
|
||||
CountriesContinentAntarctica CountriesContinent = "Antarctica"
|
||||
CountriesContinentAsia CountriesContinent = "Asia"
|
||||
CountriesContinentEurope CountriesContinent = "Europe"
|
||||
CountriesContinentNorthAmerica CountriesContinent = "North America"
|
||||
CountriesContinentOceania CountriesContinent = "Oceania"
|
||||
CountriesContinentSouthAmerica CountriesContinent = "South America"
|
||||
)
|
||||
|
||||
func (e *CountriesContinent) Scan(src interface{}) error {
|
||||
switch s := src.(type) {
|
||||
case []byte:
|
||||
*e = CountriesContinent(s)
|
||||
case string:
|
||||
*e = CountriesContinent(s)
|
||||
default:
|
||||
return fmt.Errorf("unsupported scan type for CountriesContinent: %T", src)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type NullCountriesContinent struct {
|
||||
CountriesContinent CountriesContinent `json:"countries_continent"`
|
||||
Valid bool `json:"valid"` // Valid is true if CountriesContinent is not NULL
|
||||
}
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (ns *NullCountriesContinent) Scan(value interface{}) error {
|
||||
if value == nil {
|
||||
ns.CountriesContinent, ns.Valid = "", false
|
||||
return nil
|
||||
}
|
||||
ns.Valid = true
|
||||
return ns.CountriesContinent.Scan(value)
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (ns NullCountriesContinent) Value() (driver.Value, error) {
|
||||
if !ns.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
return string(ns.CountriesContinent), nil
|
||||
}
|
||||
|
||||
type CurrencyTransactionLogsCurrencyType string
|
||||
|
||||
const (
|
||||
CurrencyTransactionLogsCurrencyTypeCash CurrencyTransactionLogsCurrencyType = "cash"
|
||||
CurrencyTransactionLogsCurrencyTypeFuel CurrencyTransactionLogsCurrencyType = "fuel"
|
||||
CurrencyTransactionLogsCurrencyTypePassengers CurrencyTransactionLogsCurrencyType = "passengers"
|
||||
)
|
||||
|
||||
func (e *CurrencyTransactionLogsCurrencyType) Scan(src interface{}) error {
|
||||
switch s := src.(type) {
|
||||
case []byte:
|
||||
*e = CurrencyTransactionLogsCurrencyType(s)
|
||||
case string:
|
||||
*e = CurrencyTransactionLogsCurrencyType(s)
|
||||
default:
|
||||
return fmt.Errorf("unsupported scan type for CurrencyTransactionLogsCurrencyType: %T", src)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type NullCurrencyTransactionLogsCurrencyType struct {
|
||||
CurrencyTransactionLogsCurrencyType CurrencyTransactionLogsCurrencyType `json:"currency_transaction_logs_currency_type"`
|
||||
Valid bool `json:"valid"` // Valid is true if CurrencyTransactionLogsCurrencyType is not NULL
|
||||
}
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (ns *NullCurrencyTransactionLogsCurrencyType) Scan(value interface{}) error {
|
||||
if value == nil {
|
||||
ns.CurrencyTransactionLogsCurrencyType, ns.Valid = "", false
|
||||
return nil
|
||||
}
|
||||
ns.Valid = true
|
||||
return ns.CurrencyTransactionLogsCurrencyType.Scan(value)
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (ns NullCurrencyTransactionLogsCurrencyType) Value() (driver.Value, error) {
|
||||
if !ns.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
return string(ns.CurrencyTransactionLogsCurrencyType), nil
|
||||
}
|
||||
|
||||
type PlanesAircraftSize string
|
||||
|
||||
const (
|
||||
PlanesAircraftSizeSmall PlanesAircraftSize = "small"
|
||||
PlanesAircraftSizeMedium PlanesAircraftSize = "medium"
|
||||
PlanesAircraftSizeLarge PlanesAircraftSize = "large"
|
||||
PlanesAircraftSizeHuge PlanesAircraftSize = "huge"
|
||||
)
|
||||
|
||||
func (e *PlanesAircraftSize) Scan(src interface{}) error {
|
||||
switch s := src.(type) {
|
||||
case []byte:
|
||||
*e = PlanesAircraftSize(s)
|
||||
case string:
|
||||
*e = PlanesAircraftSize(s)
|
||||
default:
|
||||
return fmt.Errorf("unsupported scan type for PlanesAircraftSize: %T", src)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type NullPlanesAircraftSize struct {
|
||||
PlanesAircraftSize PlanesAircraftSize `json:"planes_aircraft_size"`
|
||||
Valid bool `json:"valid"` // Valid is true if PlanesAircraftSize is not NULL
|
||||
}
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (ns *NullPlanesAircraftSize) Scan(value interface{}) error {
|
||||
if value == nil {
|
||||
ns.PlanesAircraftSize, ns.Valid = "", false
|
||||
return nil
|
||||
}
|
||||
ns.Valid = true
|
||||
return ns.PlanesAircraftSize.Scan(value)
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (ns NullPlanesAircraftSize) Value() (driver.Value, error) {
|
||||
if !ns.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
return string(ns.PlanesAircraftSize), nil
|
||||
}
|
||||
|
||||
type PlanesAircraftType string
|
||||
|
||||
const (
|
||||
PlanesAircraftTypePlane PlanesAircraftType = "plane"
|
||||
PlanesAircraftTypeHelicopter PlanesAircraftType = "helicopter"
|
||||
PlanesAircraftTypeSeaplane PlanesAircraftType = "seaplane"
|
||||
PlanesAircraftTypeSpaceship PlanesAircraftType = "spaceship"
|
||||
)
|
||||
|
||||
func (e *PlanesAircraftType) Scan(src interface{}) error {
|
||||
switch s := src.(type) {
|
||||
case []byte:
|
||||
*e = PlanesAircraftType(s)
|
||||
case string:
|
||||
*e = PlanesAircraftType(s)
|
||||
default:
|
||||
return fmt.Errorf("unsupported scan type for PlanesAircraftType: %T", src)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type NullPlanesAircraftType struct {
|
||||
PlanesAircraftType PlanesAircraftType `json:"planes_aircraft_type"`
|
||||
Valid bool `json:"valid"` // Valid is true if PlanesAircraftType is not NULL
|
||||
}
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (ns *NullPlanesAircraftType) Scan(value interface{}) error {
|
||||
if value == nil {
|
||||
ns.PlanesAircraftType, ns.Valid = "", false
|
||||
return nil
|
||||
}
|
||||
ns.Valid = true
|
||||
return ns.PlanesAircraftType.Scan(value)
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (ns NullPlanesAircraftType) Value() (driver.Value, error) {
|
||||
if !ns.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
return string(ns.PlanesAircraftType), nil
|
||||
}
|
||||
|
||||
type PlanesOperationType string
|
||||
|
||||
const (
|
||||
PlanesOperationTypePassenger PlanesOperationType = "passenger"
|
||||
PlanesOperationTypeCargo PlanesOperationType = "cargo"
|
||||
)
|
||||
|
||||
func (e *PlanesOperationType) Scan(src interface{}) error {
|
||||
switch s := src.(type) {
|
||||
case []byte:
|
||||
*e = PlanesOperationType(s)
|
||||
case string:
|
||||
*e = PlanesOperationType(s)
|
||||
default:
|
||||
return fmt.Errorf("unsupported scan type for PlanesOperationType: %T", src)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type NullPlanesOperationType struct {
|
||||
PlanesOperationType PlanesOperationType `json:"planes_operation_type"`
|
||||
Valid bool `json:"valid"` // Valid is true if PlanesOperationType is not NULL
|
||||
}
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (ns *NullPlanesOperationType) Scan(value interface{}) error {
|
||||
if value == nil {
|
||||
ns.PlanesOperationType, ns.Valid = "", false
|
||||
return nil
|
||||
}
|
||||
ns.Valid = true
|
||||
return ns.PlanesOperationType.Scan(value)
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (ns NullPlanesOperationType) Value() (driver.Value, error) {
|
||||
if !ns.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
return string(ns.PlanesOperationType), nil
|
||||
}
|
||||
|
||||
type PlayerPlanesStatus string
|
||||
|
||||
const (
|
||||
PlayerPlanesStatusIdle PlayerPlanesStatus = "idle"
|
||||
PlayerPlanesStatusMaintenance PlayerPlanesStatus = "maintenance"
|
||||
PlayerPlanesStatusBoarding PlayerPlanesStatus = "boarding"
|
||||
PlayerPlanesStatusTaxiing PlayerPlanesStatus = "taxiing"
|
||||
PlayerPlanesStatusFlying PlayerPlanesStatus = "flying"
|
||||
)
|
||||
|
||||
func (e *PlayerPlanesStatus) Scan(src interface{}) error {
|
||||
switch s := src.(type) {
|
||||
case []byte:
|
||||
*e = PlayerPlanesStatus(s)
|
||||
case string:
|
||||
*e = PlayerPlanesStatus(s)
|
||||
default:
|
||||
return fmt.Errorf("unsupported scan type for PlayerPlanesStatus: %T", src)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type NullPlayerPlanesStatus struct {
|
||||
PlayerPlanesStatus PlayerPlanesStatus `json:"player_planes_status"`
|
||||
Valid bool `json:"valid"` // Valid is true if PlayerPlanesStatus is not NULL
|
||||
}
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (ns *NullPlayerPlanesStatus) Scan(value interface{}) error {
|
||||
if value == nil {
|
||||
ns.PlayerPlanesStatus, ns.Valid = "", false
|
||||
return nil
|
||||
}
|
||||
ns.Valid = true
|
||||
return ns.PlayerPlanesStatus.Scan(value)
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (ns NullPlayerPlanesStatus) Value() (driver.Value, error) {
|
||||
if !ns.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
return string(ns.PlayerPlanesStatus), nil
|
||||
}
|
||||
|
||||
type Airport struct {
|
||||
ID uint32 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
UserID int32 `json:"user_id"`
|
||||
OriginCountryID uint16 `json:"origin_country_id"`
|
||||
Cash uint64 `json:"cash"`
|
||||
CurrentPassengers uint32 `json:"current_passengers"`
|
||||
MaxPassengerCapacity uint32 `json:"max_passenger_capacity"`
|
||||
CurrentFuel uint32 `json:"current_fuel"`
|
||||
MaxFuelCapacity uint32 `json:"max_fuel_capacity"`
|
||||
FuelGenerationRate uint32 `json:"fuel_generation_rate"`
|
||||
PassengerGenerationRate uint32 `json:"passenger_generation_rate"`
|
||||
ResourcesLastUpdatedAt time.Time `json:"resources_last_updated_at"`
|
||||
IsAvailable bool `json:"is_available"`
|
||||
PlayerLevel uint32 `json:"player_level"`
|
||||
ExperiencePoints uint64 `json:"experience_points"`
|
||||
IsDeleted sql.NullBool `json:"is_deleted"`
|
||||
}
|
||||
|
||||
type AirportBuilding struct {
|
||||
ID uint32 `json:"id"`
|
||||
AirportID uint32 `json:"airport_id"`
|
||||
BuildingID uint32 `json:"building_id"`
|
||||
RecipeID sql.NullInt32 `json:"recipe_id"`
|
||||
StorageProduct sql.NullInt32 `json:"storage_product"`
|
||||
Storage1 sql.NullInt32 `json:"storage_1"`
|
||||
Storage2 sql.NullInt32 `json:"storage_2"`
|
||||
Storage3 sql.NullInt32 `json:"storage_3"`
|
||||
Level uint32 `json:"level"`
|
||||
}
|
||||
|
||||
type AirportContract struct {
|
||||
ID uint32 `json:"id"`
|
||||
AirportID uint32 `json:"airport_id"`
|
||||
Title string `json:"title"`
|
||||
RequiredProductID uint16 `json:"required_product_id"`
|
||||
RequiredAmount uint32 `json:"required_amount"`
|
||||
CurrentAmountDelivered uint32 `json:"current_amount_delivered"`
|
||||
IsCompleted bool `json:"is_completed"`
|
||||
ExpiresAt time.Time `json:"expires_at"`
|
||||
}
|
||||
|
||||
type AirportInventory struct {
|
||||
AirportID uint32 `json:"airport_id"`
|
||||
ProductID uint16 `json:"product_id"`
|
||||
Quantity uint32 `json:"quantity"`
|
||||
}
|
||||
|
||||
type Building struct {
|
||||
ID uint32 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
MinLevel uint32 `json:"min_level"`
|
||||
ConstructionCostCash uint32 `json:"construction_cost_cash"`
|
||||
UpgradeTier sql.NullInt16 `json:"upgrade_tier"`
|
||||
UpgradeCostCashToUptier sql.NullInt32 `json:"upgrade_cost_cash_to_uptier"`
|
||||
BuildingType BuildingsBuildingType `json:"building_type"`
|
||||
Capacity sql.NullInt32 `json:"capacity"`
|
||||
StorageType NullBuildingsStorageType `json:"storage_type"`
|
||||
StorageSubtype NullBuildingsStorageSubtype `json:"storage_subtype"`
|
||||
EffectID sql.NullInt16 `json:"effect_id"`
|
||||
EffectValue sql.NullInt32 `json:"effect_value"`
|
||||
OperationSize NullBuildingsOperationSize `json:"operation_size"`
|
||||
OperationType NullBuildingsOperationType `json:"operation_type"`
|
||||
PassiveType NullBuildingsPassiveType `json:"passive_type"`
|
||||
PassiveRate sql.NullInt32 `json:"passive_rate"`
|
||||
}
|
||||
|
||||
type BuildingProduct struct {
|
||||
ID uint32 `json:"id"`
|
||||
BuildingID uint32 `json:"building_id"`
|
||||
RecipeID sql.NullInt32 `json:"recipe_id"`
|
||||
StorageProduct sql.NullInt32 `json:"storage_product"`
|
||||
Storage1 sql.NullInt32 `json:"storage_1"`
|
||||
Storage2 sql.NullInt32 `json:"storage_2"`
|
||||
Storage3 sql.NullInt32 `json:"storage_3"`
|
||||
}
|
||||
|
||||
type CompletedFlightRoutesLog struct {
|
||||
ID uint32 `json:"id"`
|
||||
OriginAirportID uint32 `json:"origin_airport_id"`
|
||||
DestinationAirportID uint32 `json:"destination_airport_id"`
|
||||
StartTime time.Time `json:"start_time"`
|
||||
EndTime sql.NullTime `json:"end_time"`
|
||||
}
|
||||
|
||||
type Country struct {
|
||||
ID uint16 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Continent CountriesContinent `json:"continent"`
|
||||
Produce1ID uint16 `json:"produce_1_id"`
|
||||
Produce2ID uint16 `json:"produce_2_id"`
|
||||
Produce3ID uint16 `json:"produce_3_id"`
|
||||
}
|
||||
|
||||
type CurrencyTransactionLog struct {
|
||||
ID uint64 `json:"id"`
|
||||
AirportID uint32 `json:"airport_id"`
|
||||
AmountChanged int32 `json:"amount_changed"`
|
||||
CurrencyType CurrencyTransactionLogsCurrencyType `json:"currency_type"`
|
||||
Reason string `json:"reason"`
|
||||
CreatedAt sql.NullTime `json:"created_at"`
|
||||
}
|
||||
|
||||
type Effect struct {
|
||||
ID uint16 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type Plane struct {
|
||||
ID uint32 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
MinLevel uint32 `json:"min_level"`
|
||||
OperationCostFuel uint32 `json:"operation_cost_fuel"`
|
||||
OperationCostCash uint32 `json:"operation_cost_cash"`
|
||||
MaxPassengers sql.NullInt32 `json:"max_passengers"`
|
||||
TravelTimeInseconds uint32 `json:"travel_time_inseconds"`
|
||||
OperationType PlanesOperationType `json:"operation_type"`
|
||||
AircraftSize PlanesAircraftSize `json:"aircraft_size"`
|
||||
AircraftType PlanesAircraftType `json:"aircraft_type"`
|
||||
BuyingCostCash uint32 `json:"buying_cost_cash"`
|
||||
CompletedFlightExperience uint32 `json:"completed_flight_experience"`
|
||||
CompletedFlightCashReward sql.NullInt32 `json:"completed_flight_cash_reward"`
|
||||
CompletedFlightCargoReward sql.NullInt32 `json:"completed_flight_cargo_reward"`
|
||||
}
|
||||
|
||||
type PlayerPlane struct {
|
||||
ID uint32 `json:"id"`
|
||||
AirportID uint32 `json:"airport_id"`
|
||||
PlaneID uint32 `json:"plane_id"`
|
||||
AssignedHangarID uint32 `json:"assigned_hangar_id"`
|
||||
CurrentBuildingID sql.NullInt32 `json:"current_building_id"`
|
||||
Status PlayerPlanesStatus `json:"status"`
|
||||
UpdatedAt sql.NullTime `json:"updated_at"`
|
||||
FlightStartTime sql.NullTime `json:"flight_start_time"`
|
||||
}
|
||||
|
||||
type Product struct {
|
||||
ID uint16 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type Recipe struct {
|
||||
ID uint32 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Ingredient1ID sql.NullInt16 `json:"ingredient_1_id"`
|
||||
Ingredient1Amount sql.NullInt32 `json:"ingredient_1_amount"`
|
||||
Ingredient2ID sql.NullInt16 `json:"ingredient_2_id"`
|
||||
Ingredient2Amount sql.NullInt32 `json:"ingredient_2_amount"`
|
||||
Ingredient3ID sql.NullInt16 `json:"ingredient_3_id"`
|
||||
Ingredient3Amount sql.NullInt32 `json:"ingredient_3_amount"`
|
||||
ProductID uint16 `json:"product_id"`
|
||||
YieldAmount uint32 `json:"yield_amount"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
ID int32 `json:"id"`
|
||||
Username string `json:"username"`
|
||||
PasswordHash string `json:"password_hash"`
|
||||
CreatedAt sql.NullTime `json:"created_at"`
|
||||
DeletedAt sql.NullTime `json:"deleted_at"`
|
||||
}
|
||||
108
internal/db/querier.go
Normal file
108
internal/db/querier.go
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
type Querier interface {
|
||||
AddBuildingToAirportByUsername(ctx context.Context, arg AddBuildingToAirportByUsernameParams) (sql.Result, error)
|
||||
AddContractToAirport(ctx context.Context, arg AddContractToAirportParams) (sql.Result, error)
|
||||
AddCountry(ctx context.Context, arg AddCountryParams) (sql.Result, error)
|
||||
// ============================================================================
|
||||
// 4. BUILDINGS & PRODUCTION ENGINE
|
||||
// ============================================================================
|
||||
AddRecipe(ctx context.Context, arg AddRecipeParams) (sql.Result, error)
|
||||
Addproduct(ctx context.Context, name string) (sql.Result, error)
|
||||
// ============================================================================
|
||||
// 5. FLEET & DYNAMIC INFRASTRUCTURE OPERATIONS
|
||||
// ============================================================================
|
||||
BuyPlaneForPlayer(ctx context.Context, arg BuyPlaneForPlayerParams) (sql.Result, error)
|
||||
CheckHangarOccupancy(ctx context.Context, currentBuildingID sql.NullInt32) (int64, error)
|
||||
CheckHangarOccupancyByUsername(ctx context.Context, arg CheckHangarOccupancyByUsernameParams) (int64, error)
|
||||
// specific hangar
|
||||
CheckRunwayOccupancyByUsername(ctx context.Context, arg CheckRunwayOccupancyByUsernameParams) (int64, error)
|
||||
CompleteContract(ctx context.Context, id uint32) error
|
||||
// ============================================================================
|
||||
// 2. AIRPORT CORE MANAGEMENT
|
||||
// ============================================================================
|
||||
// airport row management
|
||||
CreateAirportByUserName(ctx context.Context, arg CreateAirportByUserNameParams) (sql.Result, error)
|
||||
// ============================================================================
|
||||
// 1. AUTHENTICATION & USERS
|
||||
// ============================================================================
|
||||
CreateUser(ctx context.Context, arg CreateUserParams) (sql.Result, error)
|
||||
DeleteAirportByUserName(ctx context.Context, username string) error
|
||||
DeleteUserByUsername(ctx context.Context, username string) error
|
||||
FindAvailableInfrastructure(ctx context.Context, arg FindAvailableInfrastructureParams) (uint32, error)
|
||||
FindAvailableInfrastructureForPlane(ctx context.Context, arg FindAvailableInfrastructureForPlaneParams) (uint32, error)
|
||||
// ============================================================================
|
||||
// 7. PROGRESSION CONTRACTS & ECONOMY LOGS
|
||||
// ============================================================================
|
||||
GetActiveContracts(ctx context.Context, airportID uint32) ([]GetActiveContractsRow, error)
|
||||
GetActiveContractsWithProduct(ctx context.Context, airportID uint32) ([]GetActiveContractsWithProductRow, error)
|
||||
// ============================================================================
|
||||
// 8. MISSING QUERIES (added for TUI — regenerate sqlc after adding these)
|
||||
// ============================================================================
|
||||
GetAirportBuildingsByAirportId(ctx context.Context, airportID uint32) ([]GetAirportBuildingsByAirportIdRow, error)
|
||||
GetAirportBuildingsByUsername(ctx context.Context, username string) ([]GetAirportBuildingsByUsernameRow, error)
|
||||
GetAirportByUserId(ctx context.Context, userID int32) (GetAirportByUserIdRow, error)
|
||||
GetAirportByUserName(ctx context.Context, username string) (GetAirportByUserNameRow, error)
|
||||
GetAllBuildings(ctx context.Context) ([]GetAllBuildingsRow, error)
|
||||
// ============================================================================
|
||||
// 3. country
|
||||
// ============================================================================
|
||||
GetAllCountries(ctx context.Context) ([]GetAllCountriesRow, error)
|
||||
GetAllPlanes(ctx context.Context) ([]Plane, error)
|
||||
GetAllProducts(ctx context.Context) ([]Product, error)
|
||||
GetCountryById(ctx context.Context, id uint16) (GetCountryByIdRow, error)
|
||||
GetCountryByName(ctx context.Context, name string) (GetCountryByNameRow, error)
|
||||
GetPlaneById(ctx context.Context, id uint32) (Plane, error)
|
||||
GetPlanesByAircraftSize(ctx context.Context, aircraftSize PlanesAircraftSize) ([]Plane, error)
|
||||
GetPlanesByAircraftType(ctx context.Context, aircraftType PlanesAircraftType) ([]Plane, error)
|
||||
GetPlanesByMinLevel(ctx context.Context, minLevel uint32) ([]Plane, error)
|
||||
GetPlanesByOperationType(ctx context.Context, operationType PlanesOperationType) ([]Plane, error)
|
||||
// ============================================================================
|
||||
// 6. TIME-BASED FLIGHT ENGINE
|
||||
// ============================================================================
|
||||
GetPlanesReadyToLand(ctx context.Context) ([]GetPlanesReadyToLandRow, error)
|
||||
// specific runway
|
||||
GetPlanesReadyToLandByUsername(ctx context.Context, username string) ([]GetPlanesReadyToLandByUsernameRow, error)
|
||||
GetPlayerFleet(ctx context.Context, airportID uint32) ([]GetPlayerFleetRow, error)
|
||||
GetPlayerPlanesByUsername(ctx context.Context, username string) ([]GetPlayerPlanesByUsernameRow, error)
|
||||
GetProductById(ctx context.Context, id uint16) (Product, error)
|
||||
GetUserByUsername(ctx context.Context, username string) (GetUserByUsernameRow, error)
|
||||
GetUserIdByUsername(ctx context.Context, username string) (int32, error)
|
||||
LogCompletedFlightRoute(ctx context.Context, arg LogCompletedFlightRouteParams) error
|
||||
LogCurrencyTransaction(ctx context.Context, arg LogCurrencyTransactionParams) error
|
||||
UpdateAirportCash(ctx context.Context, arg UpdateAirportCashParams) error
|
||||
// airport resource management
|
||||
UpdateAirportCurrencies(ctx context.Context, arg UpdateAirportCurrenciesParams) error
|
||||
UpdateAirportFuel(ctx context.Context, arg UpdateAirportFuelParams) error
|
||||
UpdateAirportFuelRate(ctx context.Context, arg UpdateAirportFuelRateParams) error
|
||||
UpdateAirportMaxFuel(ctx context.Context, arg UpdateAirportMaxFuelParams) error
|
||||
UpdateAirportPassengerRate(ctx context.Context, arg UpdateAirportPassengerRateParams) error
|
||||
UpdateAirportResources(ctx context.Context, id uint32) error
|
||||
UpdateAirportResourcesUpdated(ctx context.Context, arg UpdateAirportResourcesUpdatedParams) error
|
||||
UpdateAirportmaxPassengers(ctx context.Context, arg UpdateAirportmaxPassengersParams) error
|
||||
UpdateAirportpassengers(ctx context.Context, arg UpdateAirportpassengersParams) error
|
||||
UpdateContractDelivery(ctx context.Context, arg UpdateContractDeliveryParams) error
|
||||
UpdatePlaneState(ctx context.Context, arg UpdatePlaneStateParams) error
|
||||
UpdatePlayerPlaneState(ctx context.Context, arg UpdatePlayerPlaneStateParams) error
|
||||
UpdateUserPasswordByUserName(ctx context.Context, arg UpdateUserPasswordByUserNameParams) error
|
||||
addBuilding(ctx context.Context, arg addBuildingParams) (sql.Result, error)
|
||||
addOperationalBuilding(ctx context.Context, arg addOperationalBuildingParams) (sql.Result, error)
|
||||
addPassiveProductionBuilding(ctx context.Context, arg addPassiveProductionBuildingParams) (sql.Result, error)
|
||||
// planes & fleet management
|
||||
addPlane(ctx context.Context, arg addPlaneParams) (sql.Result, error)
|
||||
addPlaneToAirportByUsername(ctx context.Context, arg addPlaneToAirportByUsernameParams) (sql.Result, error)
|
||||
addStorageBuilding(ctx context.Context, arg addStorageBuildingParams) (sql.Result, error)
|
||||
updatePlayerExperience(ctx context.Context, arg updatePlayerExperienceParams) error
|
||||
updatePlayerLevel(ctx context.Context, arg updatePlayerLevelParams) error
|
||||
}
|
||||
|
||||
var _ Querier = (*Queries)(nil)
|
||||
1795
internal/db/queries.sql.go
Normal file
1795
internal/db/queries.sql.go
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue