// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.31.1 // source: queries.sql package db import ( "context" "database/sql" "time" ) const AddBuildingToAirportByUsername = `-- name: AddBuildingToAirportByUsername :execresult INSERT INTO airport_buildings (airport_id, building_id) VALUES ((select id from airports where user_id = (select id from users where username = ?)), ?) ` type AddBuildingToAirportByUsernameParams struct { Username string `json:"username"` BuildingID uint32 `json:"building_id"` } func (q *Queries) AddBuildingToAirportByUsername(ctx context.Context, arg AddBuildingToAirportByUsernameParams) (sql.Result, error) { return q.db.ExecContext(ctx, AddBuildingToAirportByUsername, arg.Username, arg.BuildingID) } const AddContractToAirport = `-- name: AddContractToAirport :execresult INSERT INTO airport_contracts (airport_id, title, required_product_id, required_amount, expires_at) VALUES (?, ?, ?, ?, ?) ` type AddContractToAirportParams struct { AirportID uint32 `json:"airport_id"` Title string `json:"title"` RequiredProductID uint16 `json:"required_product_id"` RequiredAmount uint32 `json:"required_amount"` ExpiresAt time.Time `json:"expires_at"` } func (q *Queries) AddContractToAirport(ctx context.Context, arg AddContractToAirportParams) (sql.Result, error) { return q.db.ExecContext(ctx, AddContractToAirport, arg.AirportID, arg.Title, arg.RequiredProductID, arg.RequiredAmount, arg.ExpiresAt, ) } const AddCountry = `-- name: AddCountry :execresult INSERT INTO countries (name,continent,produce_1_id,produce_2_id,produce_3_id) VALUES (?, ?, ?, ?, ?) ` type AddCountryParams struct { 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"` } func (q *Queries) AddCountry(ctx context.Context, arg AddCountryParams) (sql.Result, error) { return q.db.ExecContext(ctx, AddCountry, arg.Name, arg.Continent, arg.Produce1ID, arg.Produce2ID, arg.Produce3ID, ) } const AddRecipe = `-- name: AddRecipe :execresult INSERT INTO recipes (name, ingredient_1_id, ingredient_1_amount, ingredient_2_id, ingredient_2_amount, ingredient_3_id, ingredient_3_amount, product_id, yield_amount) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) ` type AddRecipeParams struct { 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"` } // ============================================================================ // 4. BUILDINGS & PRODUCTION ENGINE // ============================================================================ func (q *Queries) AddRecipe(ctx context.Context, arg AddRecipeParams) (sql.Result, error) { return q.db.ExecContext(ctx, AddRecipe, arg.Name, arg.Ingredient1ID, arg.Ingredient1Amount, arg.Ingredient2ID, arg.Ingredient2Amount, arg.Ingredient3ID, arg.Ingredient3Amount, arg.ProductID, arg.YieldAmount, ) } const Addproduct = `-- name: Addproduct :execresult insert into products (name) values (?) ` func (q *Queries) Addproduct(ctx context.Context, name string) (sql.Result, error) { return q.db.ExecContext(ctx, Addproduct, name) } const BuyPlaneForPlayer = `-- name: BuyPlaneForPlayer :execresult INSERT INTO player_planes (airport_id, plane_id, assigned_hangar_id, current_building_id, status) VALUES (?, ?, ?, ?, 'idle') ` type BuyPlaneForPlayerParams struct { AirportID uint32 `json:"airport_id"` PlaneID uint32 `json:"plane_id"` AssignedHangarID uint32 `json:"assigned_hangar_id"` CurrentBuildingID sql.NullInt32 `json:"current_building_id"` } // ============================================================================ // 5. FLEET & DYNAMIC INFRASTRUCTURE OPERATIONS // ============================================================================ func (q *Queries) BuyPlaneForPlayer(ctx context.Context, arg BuyPlaneForPlayerParams) (sql.Result, error) { return q.db.ExecContext(ctx, BuyPlaneForPlayer, arg.AirportID, arg.PlaneID, arg.AssignedHangarID, arg.CurrentBuildingID, ) } const CheckHangarOccupancy = `-- name: CheckHangarOccupancy :one SELECT COUNT(*) AS total_parked FROM player_planes WHERE current_building_id = ? ` func (q *Queries) CheckHangarOccupancy(ctx context.Context, currentBuildingID sql.NullInt32) (int64, error) { row := q.db.QueryRowContext(ctx, CheckHangarOccupancy, currentBuildingID) var total_parked int64 err := row.Scan(&total_parked) return total_parked, err } const CheckHangarOccupancyByUsername = `-- name: CheckHangarOccupancyByUsername :one SELECT COUNT(*) AS total_parked FROM player_planes pp JOIN airport_buildings ab ON pp.current_building_id = ab.id WHERE ab.airport_id = (select id from airports where user_id = (select id from users where username = ?)) AND ab.building_id = ? ` type CheckHangarOccupancyByUsernameParams struct { Username string `json:"username"` BuildingID uint32 `json:"building_id"` } func (q *Queries) CheckHangarOccupancyByUsername(ctx context.Context, arg CheckHangarOccupancyByUsernameParams) (int64, error) { row := q.db.QueryRowContext(ctx, CheckHangarOccupancyByUsername, arg.Username, arg.BuildingID) var total_parked int64 err := row.Scan(&total_parked) return total_parked, err } const CheckRunwayOccupancyByUsername = `-- name: CheckRunwayOccupancyByUsername :one -- SELECT COUNT(*) AS total_occupied FROM player_planes pp JOIN airport_buildings ab ON pp.current_building_id = ab.id WHERE ab.airport_id = (select id from airports where user_id = (select id from users where username = ?)) AND ab.building_id = ? ` type CheckRunwayOccupancyByUsernameParams struct { Username string `json:"username"` BuildingID uint32 `json:"building_id"` } // specific hangar func (q *Queries) CheckRunwayOccupancyByUsername(ctx context.Context, arg CheckRunwayOccupancyByUsernameParams) (int64, error) { row := q.db.QueryRowContext(ctx, CheckRunwayOccupancyByUsername, arg.Username, arg.BuildingID) var total_occupied int64 err := row.Scan(&total_occupied) return total_occupied, err } const CompleteContract = `-- name: CompleteContract :exec UPDATE airport_contracts SET is_completed = TRUE WHERE id = ? ` func (q *Queries) CompleteContract(ctx context.Context, id uint32) error { _, err := q.db.ExecContext(ctx, CompleteContract, id) return err } const CreateAirportByUserName = `-- name: CreateAirportByUserName :execresult INSERT INTO airports (name, user_id, origin_country_id) VALUES (?, (SELECT id FROM users WHERE username = ?), ?) ` type CreateAirportByUserNameParams struct { Name string `json:"name"` Username string `json:"username"` OriginCountryID uint16 `json:"origin_country_id"` } // ============================================================================ // 2. AIRPORT CORE MANAGEMENT // ============================================================================ // airport row management func (q *Queries) CreateAirportByUserName(ctx context.Context, arg CreateAirportByUserNameParams) (sql.Result, error) { return q.db.ExecContext(ctx, CreateAirportByUserName, arg.Name, arg.Username, arg.OriginCountryID) } const CreateUser = `-- name: CreateUser :execresult INSERT INTO users (username, password_hash) VALUES (?, ?) ` type CreateUserParams struct { Username string `json:"username"` PasswordHash string `json:"password_hash"` } // ============================================================================ // 1. AUTHENTICATION & USERS // ============================================================================ func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (sql.Result, error) { return q.db.ExecContext(ctx, CreateUser, arg.Username, arg.PasswordHash) } const DeleteAirportByUserName = `-- name: DeleteAirportByUserName :exec UPDATE airports SET is_deleted = TRUE WHERE user_id = (SELECT id FROM users WHERE username = ?) ` func (q *Queries) DeleteAirportByUserName(ctx context.Context, username string) error { _, err := q.db.ExecContext(ctx, DeleteAirportByUserName, username) return err } const DeleteUserByUsername = `-- name: DeleteUserByUsername :exec UPDATE users SET deleted_at = CURRENT_TIMESTAMP WHERE username = ? ` func (q *Queries) DeleteUserByUsername(ctx context.Context, username string) error { _, err := q.db.ExecContext(ctx, DeleteUserByUsername, username) return err } const FindAvailableInfrastructure = `-- name: FindAvailableInfrastructure :one SELECT ab.id FROM airport_buildings ab JOIN buildings b ON ab.building_id = b.id LEFT JOIN player_planes pp ON ab.id = pp.current_building_id WHERE ab.airport_id = ? AND b.operation_type = ? -- 'runway' or 'service' (service bay) AND b.operation_size = ? -- matches plane's aircraft_size requirement AND pp.id IS NULL -- Ensures no other plane is physically here right now LIMIT 1 ` type FindAvailableInfrastructureParams struct { AirportID uint32 `json:"airport_id"` OperationType NullBuildingsOperationType `json:"operation_type"` OperationSize NullBuildingsOperationSize `json:"operation_size"` } func (q *Queries) FindAvailableInfrastructure(ctx context.Context, arg FindAvailableInfrastructureParams) (uint32, error) { row := q.db.QueryRowContext(ctx, FindAvailableInfrastructure, arg.AirportID, arg.OperationType, arg.OperationSize) var id uint32 err := row.Scan(&id) return id, err } const FindAvailableInfrastructureForPlane = `-- name: FindAvailableInfrastructureForPlane :one SELECT ab.id FROM airport_buildings ab JOIN buildings b ON ab.building_id = b.id LEFT JOIN player_planes pp ON ab.id = pp.current_building_id WHERE ab.airport_id = (select id from airports where user_id = (select id from users where username = ?)) AND b.operation_type = ? -- 'runway' or 'service' (service bay) AND b.operation_size = ? -- matches plane's aircraft_size requirement AND pp.id IS NULL -- Ensures no other plane is physically here right now LIMIT 1 ` type FindAvailableInfrastructureForPlaneParams struct { Username string `json:"username"` OperationType NullBuildingsOperationType `json:"operation_type"` OperationSize NullBuildingsOperationSize `json:"operation_size"` } func (q *Queries) FindAvailableInfrastructureForPlane(ctx context.Context, arg FindAvailableInfrastructureForPlaneParams) (uint32, error) { row := q.db.QueryRowContext(ctx, FindAvailableInfrastructureForPlane, arg.Username, arg.OperationType, arg.OperationSize) var id uint32 err := row.Scan(&id) return id, err } const GetActiveContracts = `-- name: GetActiveContracts :many SELECT id, title, required_product_id, required_amount, current_amount_delivered, is_completed, expires_at FROM airport_contracts WHERE airport_id = ? AND is_completed = FALSE AND expires_at > NOW() ` type GetActiveContractsRow struct { ID uint32 `json:"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"` } // ============================================================================ // 7. PROGRESSION CONTRACTS & ECONOMY LOGS // ============================================================================ func (q *Queries) GetActiveContracts(ctx context.Context, airportID uint32) ([]GetActiveContractsRow, error) { rows, err := q.db.QueryContext(ctx, GetActiveContracts, airportID) if err != nil { return nil, err } defer rows.Close() items := []GetActiveContractsRow{} for rows.Next() { var i GetActiveContractsRow if err := rows.Scan( &i.ID, &i.Title, &i.RequiredProductID, &i.RequiredAmount, &i.CurrentAmountDelivered, &i.IsCompleted, &i.ExpiresAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const GetActiveContractsWithProduct = `-- name: GetActiveContractsWithProduct :many SELECT ac.id, ac.title, ac.required_product_id, ac.required_amount, ac.current_amount_delivered, ac.is_completed, ac.expires_at, p.name AS product_name FROM airport_contracts ac JOIN products p ON ac.required_product_id = p.id WHERE ac.airport_id = ? AND ac.is_completed = FALSE AND ac.expires_at > NOW() ORDER BY ac.expires_at ` type GetActiveContractsWithProductRow struct { ID uint32 `json:"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"` ProductName string `json:"product_name"` } func (q *Queries) GetActiveContractsWithProduct(ctx context.Context, airportID uint32) ([]GetActiveContractsWithProductRow, error) { rows, err := q.db.QueryContext(ctx, GetActiveContractsWithProduct, airportID) if err != nil { return nil, err } defer rows.Close() items := []GetActiveContractsWithProductRow{} for rows.Next() { var i GetActiveContractsWithProductRow if err := rows.Scan( &i.ID, &i.Title, &i.RequiredProductID, &i.RequiredAmount, &i.CurrentAmountDelivered, &i.IsCompleted, &i.ExpiresAt, &i.ProductName, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const GetAirportBuildingsByAirportId = `-- name: GetAirportBuildingsByAirportId :many SELECT ab.id, ab.airport_id, ab.building_id, ab.level, b.name, b.building_type, b.operation_size, b.operation_type, b.capacity, b.storage_type FROM airport_buildings ab JOIN buildings b ON ab.building_id = b.id WHERE ab.airport_id = ? ` type GetAirportBuildingsByAirportIdRow struct { ID uint32 `json:"id"` AirportID uint32 `json:"airport_id"` BuildingID uint32 `json:"building_id"` Level uint32 `json:"level"` Name string `json:"name"` BuildingType BuildingsBuildingType `json:"building_type"` OperationSize NullBuildingsOperationSize `json:"operation_size"` OperationType NullBuildingsOperationType `json:"operation_type"` Capacity sql.NullInt32 `json:"capacity"` StorageType NullBuildingsStorageType `json:"storage_type"` } // ============================================================================ // 8. MISSING QUERIES (added for TUI — regenerate sqlc after adding these) // ============================================================================ func (q *Queries) GetAirportBuildingsByAirportId(ctx context.Context, airportID uint32) ([]GetAirportBuildingsByAirportIdRow, error) { rows, err := q.db.QueryContext(ctx, GetAirportBuildingsByAirportId, airportID) if err != nil { return nil, err } defer rows.Close() items := []GetAirportBuildingsByAirportIdRow{} for rows.Next() { var i GetAirportBuildingsByAirportIdRow if err := rows.Scan( &i.ID, &i.AirportID, &i.BuildingID, &i.Level, &i.Name, &i.BuildingType, &i.OperationSize, &i.OperationType, &i.Capacity, &i.StorageType, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const GetAirportBuildingsByUsername = `-- name: GetAirportBuildingsByUsername :many SELECT ab.id AS airport_building_id,b.building_type , b.id, b.name, b.min_level, b.construction_cost_cash, b.upgrade_tier, b.upgrade_cost_cash_to_uptier, b.building_type, b.capacity, b.storage_type, b.storage_subtype, b.effect_id, b.effect_value, b.operation_size, b.operation_type, b.passive_type, b.passive_rate FROM airport_buildings ab JOIN buildings b ON ab.building_id = b.id WHERE ab.airport_id = (select id from airports where user_id = (select id from users where username = ?)) ` type GetAirportBuildingsByUsernameRow struct { AirportBuildingID uint32 `json:"airport_building_id"` BuildingType BuildingsBuildingType `json:"building_type"` 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_2 BuildingsBuildingType `json:"building_type_2"` 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"` } func (q *Queries) GetAirportBuildingsByUsername(ctx context.Context, username string) ([]GetAirportBuildingsByUsernameRow, error) { rows, err := q.db.QueryContext(ctx, GetAirportBuildingsByUsername, username) if err != nil { return nil, err } defer rows.Close() items := []GetAirportBuildingsByUsernameRow{} for rows.Next() { var i GetAirportBuildingsByUsernameRow if err := rows.Scan( &i.AirportBuildingID, &i.BuildingType, &i.ID, &i.Name, &i.MinLevel, &i.ConstructionCostCash, &i.UpgradeTier, &i.UpgradeCostCashToUptier, &i.BuildingType_2, &i.Capacity, &i.StorageType, &i.StorageSubtype, &i.EffectID, &i.EffectValue, &i.OperationSize, &i.OperationType, &i.PassiveType, &i.PassiveRate, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const GetAirportByUserId = `-- name: GetAirportByUserId :one SELECT id, name, user_id, origin_country_id, cash, current_passengers, max_passenger_capacity, current_fuel, max_fuel_capacity, is_available, player_level, experience_points, passenger_generation_rate, fuel_generation_rate, resources_last_updated_at, is_deleted FROM airports WHERE user_id = ? LIMIT 1 ` type GetAirportByUserIdRow 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"` IsAvailable bool `json:"is_available"` PlayerLevel uint32 `json:"player_level"` ExperiencePoints uint64 `json:"experience_points"` PassengerGenerationRate uint32 `json:"passenger_generation_rate"` FuelGenerationRate uint32 `json:"fuel_generation_rate"` ResourcesLastUpdatedAt time.Time `json:"resources_last_updated_at"` IsDeleted sql.NullBool `json:"is_deleted"` } func (q *Queries) GetAirportByUserId(ctx context.Context, userID int32) (GetAirportByUserIdRow, error) { row := q.db.QueryRowContext(ctx, GetAirportByUserId, userID) var i GetAirportByUserIdRow err := row.Scan( &i.ID, &i.Name, &i.UserID, &i.OriginCountryID, &i.Cash, &i.CurrentPassengers, &i.MaxPassengerCapacity, &i.CurrentFuel, &i.MaxFuelCapacity, &i.IsAvailable, &i.PlayerLevel, &i.ExperiencePoints, &i.PassengerGenerationRate, &i.FuelGenerationRate, &i.ResourcesLastUpdatedAt, &i.IsDeleted, ) return i, err } const GetAirportByUserName = `-- name: GetAirportByUserName :one SELECT id, name, user_id, origin_country_id, cash, current_passengers, max_passenger_capacity, current_fuel, max_fuel_capacity, is_available, player_level, experience_points ,passenger_generation_rate, fuel_generation_rate, resources_last_updated_at, is_deleted FROM airports WHERE user_id = (SELECT id FROM users WHERE username = ?) LIMIT 1 ` type GetAirportByUserNameRow 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"` IsAvailable bool `json:"is_available"` PlayerLevel uint32 `json:"player_level"` ExperiencePoints uint64 `json:"experience_points"` PassengerGenerationRate uint32 `json:"passenger_generation_rate"` FuelGenerationRate uint32 `json:"fuel_generation_rate"` ResourcesLastUpdatedAt time.Time `json:"resources_last_updated_at"` IsDeleted sql.NullBool `json:"is_deleted"` } func (q *Queries) GetAirportByUserName(ctx context.Context, username string) (GetAirportByUserNameRow, error) { row := q.db.QueryRowContext(ctx, GetAirportByUserName, username) var i GetAirportByUserNameRow err := row.Scan( &i.ID, &i.Name, &i.UserID, &i.OriginCountryID, &i.Cash, &i.CurrentPassengers, &i.MaxPassengerCapacity, &i.CurrentFuel, &i.MaxFuelCapacity, &i.IsAvailable, &i.PlayerLevel, &i.ExperiencePoints, &i.PassengerGenerationRate, &i.FuelGenerationRate, &i.ResourcesLastUpdatedAt, &i.IsDeleted, ) return i, err } const GetAllBuildings = `-- name: GetAllBuildings :many SELECT id, name, min_level, construction_cost_cash, upgrade_tier, building_type, capacity, storage_type, storage_subtype, operation_size, operation_type, passive_type, passive_rate FROM buildings ORDER BY building_type, name ` type GetAllBuildingsRow 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"` BuildingType BuildingsBuildingType `json:"building_type"` Capacity sql.NullInt32 `json:"capacity"` StorageType NullBuildingsStorageType `json:"storage_type"` StorageSubtype NullBuildingsStorageSubtype `json:"storage_subtype"` OperationSize NullBuildingsOperationSize `json:"operation_size"` OperationType NullBuildingsOperationType `json:"operation_type"` PassiveType NullBuildingsPassiveType `json:"passive_type"` PassiveRate sql.NullInt32 `json:"passive_rate"` } func (q *Queries) GetAllBuildings(ctx context.Context) ([]GetAllBuildingsRow, error) { rows, err := q.db.QueryContext(ctx, GetAllBuildings) if err != nil { return nil, err } defer rows.Close() items := []GetAllBuildingsRow{} for rows.Next() { var i GetAllBuildingsRow if err := rows.Scan( &i.ID, &i.Name, &i.MinLevel, &i.ConstructionCostCash, &i.UpgradeTier, &i.BuildingType, &i.Capacity, &i.StorageType, &i.StorageSubtype, &i.OperationSize, &i.OperationType, &i.PassiveType, &i.PassiveRate, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const GetAllCountries = `-- name: GetAllCountries :many SELECT id, name FROM countries ` type GetAllCountriesRow struct { ID uint16 `json:"id"` Name string `json:"name"` } // ============================================================================ // 3. country // ============================================================================ func (q *Queries) GetAllCountries(ctx context.Context) ([]GetAllCountriesRow, error) { rows, err := q.db.QueryContext(ctx, GetAllCountries) if err != nil { return nil, err } defer rows.Close() items := []GetAllCountriesRow{} for rows.Next() { var i GetAllCountriesRow if err := rows.Scan(&i.ID, &i.Name); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const GetAllPlanes = `-- name: GetAllPlanes :many SELECT id, name, min_level, operation_cost_fuel, operation_cost_cash, max_passengers, travel_time_inseconds, operation_type, aircraft_size, aircraft_type, buying_cost_cash, completed_flight_experience, completed_flight_cash_reward, completed_flight_cargo_reward FROM planes ` func (q *Queries) GetAllPlanes(ctx context.Context) ([]Plane, error) { rows, err := q.db.QueryContext(ctx, GetAllPlanes) if err != nil { return nil, err } defer rows.Close() items := []Plane{} for rows.Next() { var i Plane if err := rows.Scan( &i.ID, &i.Name, &i.MinLevel, &i.OperationCostFuel, &i.OperationCostCash, &i.MaxPassengers, &i.TravelTimeInseconds, &i.OperationType, &i.AircraftSize, &i.AircraftType, &i.BuyingCostCash, &i.CompletedFlightExperience, &i.CompletedFlightCashReward, &i.CompletedFlightCargoReward, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const GetAllProducts = `-- name: GetAllProducts :many select id, name from products ` func (q *Queries) GetAllProducts(ctx context.Context) ([]Product, error) { rows, err := q.db.QueryContext(ctx, GetAllProducts) if err != nil { return nil, err } defer rows.Close() items := []Product{} for rows.Next() { var i Product if err := rows.Scan(&i.ID, &i.Name); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const GetCountryById = `-- name: GetCountryById :one SELECT id, name FROM countries WHERE id = ? ` type GetCountryByIdRow struct { ID uint16 `json:"id"` Name string `json:"name"` } func (q *Queries) GetCountryById(ctx context.Context, id uint16) (GetCountryByIdRow, error) { row := q.db.QueryRowContext(ctx, GetCountryById, id) var i GetCountryByIdRow err := row.Scan(&i.ID, &i.Name) return i, err } const GetCountryByName = `-- name: GetCountryByName :one SELECT id, name FROM countries WHERE name = ? ` type GetCountryByNameRow struct { ID uint16 `json:"id"` Name string `json:"name"` } func (q *Queries) GetCountryByName(ctx context.Context, name string) (GetCountryByNameRow, error) { row := q.db.QueryRowContext(ctx, GetCountryByName, name) var i GetCountryByNameRow err := row.Scan(&i.ID, &i.Name) return i, err } const GetPlaneById = `-- name: GetPlaneById :one SELECT id, name, min_level, operation_cost_fuel, operation_cost_cash, max_passengers, travel_time_inseconds, operation_type, aircraft_size, aircraft_type, buying_cost_cash, completed_flight_experience, completed_flight_cash_reward, completed_flight_cargo_reward FROM planes WHERE id = ? ` func (q *Queries) GetPlaneById(ctx context.Context, id uint32) (Plane, error) { row := q.db.QueryRowContext(ctx, GetPlaneById, id) var i Plane err := row.Scan( &i.ID, &i.Name, &i.MinLevel, &i.OperationCostFuel, &i.OperationCostCash, &i.MaxPassengers, &i.TravelTimeInseconds, &i.OperationType, &i.AircraftSize, &i.AircraftType, &i.BuyingCostCash, &i.CompletedFlightExperience, &i.CompletedFlightCashReward, &i.CompletedFlightCargoReward, ) return i, err } const GetPlanesByAircraftSize = `-- name: GetPlanesByAircraftSize :many SELECT id, name, min_level, operation_cost_fuel, operation_cost_cash, max_passengers, travel_time_inseconds, operation_type, aircraft_size, aircraft_type, buying_cost_cash, completed_flight_experience, completed_flight_cash_reward, completed_flight_cargo_reward FROM planes WHERE aircraft_size = ? ` func (q *Queries) GetPlanesByAircraftSize(ctx context.Context, aircraftSize PlanesAircraftSize) ([]Plane, error) { rows, err := q.db.QueryContext(ctx, GetPlanesByAircraftSize, aircraftSize) if err != nil { return nil, err } defer rows.Close() items := []Plane{} for rows.Next() { var i Plane if err := rows.Scan( &i.ID, &i.Name, &i.MinLevel, &i.OperationCostFuel, &i.OperationCostCash, &i.MaxPassengers, &i.TravelTimeInseconds, &i.OperationType, &i.AircraftSize, &i.AircraftType, &i.BuyingCostCash, &i.CompletedFlightExperience, &i.CompletedFlightCashReward, &i.CompletedFlightCargoReward, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const GetPlanesByAircraftType = `-- name: GetPlanesByAircraftType :many SELECT id, name, min_level, operation_cost_fuel, operation_cost_cash, max_passengers, travel_time_inseconds, operation_type, aircraft_size, aircraft_type, buying_cost_cash, completed_flight_experience, completed_flight_cash_reward, completed_flight_cargo_reward FROM planes WHERE aircraft_type = ? ` func (q *Queries) GetPlanesByAircraftType(ctx context.Context, aircraftType PlanesAircraftType) ([]Plane, error) { rows, err := q.db.QueryContext(ctx, GetPlanesByAircraftType, aircraftType) if err != nil { return nil, err } defer rows.Close() items := []Plane{} for rows.Next() { var i Plane if err := rows.Scan( &i.ID, &i.Name, &i.MinLevel, &i.OperationCostFuel, &i.OperationCostCash, &i.MaxPassengers, &i.TravelTimeInseconds, &i.OperationType, &i.AircraftSize, &i.AircraftType, &i.BuyingCostCash, &i.CompletedFlightExperience, &i.CompletedFlightCashReward, &i.CompletedFlightCargoReward, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const GetPlanesByMinLevel = `-- name: GetPlanesByMinLevel :many SELECT id, name, min_level, operation_cost_fuel, operation_cost_cash, max_passengers, travel_time_inseconds, operation_type, aircraft_size, aircraft_type, buying_cost_cash, completed_flight_experience, completed_flight_cash_reward, completed_flight_cargo_reward FROM planes WHERE min_level <= ? ` func (q *Queries) GetPlanesByMinLevel(ctx context.Context, minLevel uint32) ([]Plane, error) { rows, err := q.db.QueryContext(ctx, GetPlanesByMinLevel, minLevel) if err != nil { return nil, err } defer rows.Close() items := []Plane{} for rows.Next() { var i Plane if err := rows.Scan( &i.ID, &i.Name, &i.MinLevel, &i.OperationCostFuel, &i.OperationCostCash, &i.MaxPassengers, &i.TravelTimeInseconds, &i.OperationType, &i.AircraftSize, &i.AircraftType, &i.BuyingCostCash, &i.CompletedFlightExperience, &i.CompletedFlightCashReward, &i.CompletedFlightCargoReward, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const GetPlanesByOperationType = `-- name: GetPlanesByOperationType :many SELECT id, name, min_level, operation_cost_fuel, operation_cost_cash, max_passengers, travel_time_inseconds, operation_type, aircraft_size, aircraft_type, buying_cost_cash, completed_flight_experience, completed_flight_cash_reward, completed_flight_cargo_reward FROM planes WHERE operation_type = ? ` func (q *Queries) GetPlanesByOperationType(ctx context.Context, operationType PlanesOperationType) ([]Plane, error) { rows, err := q.db.QueryContext(ctx, GetPlanesByOperationType, operationType) if err != nil { return nil, err } defer rows.Close() items := []Plane{} for rows.Next() { var i Plane if err := rows.Scan( &i.ID, &i.Name, &i.MinLevel, &i.OperationCostFuel, &i.OperationCostCash, &i.MaxPassengers, &i.TravelTimeInseconds, &i.OperationType, &i.AircraftSize, &i.AircraftType, &i.BuyingCostCash, &i.CompletedFlightExperience, &i.CompletedFlightCashReward, &i.CompletedFlightCargoReward, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const GetPlanesReadyToLand = `-- name: GetPlanesReadyToLand :many SELECT pp.id AS player_plane_id, pp.airport_id, pp.assigned_hangar_id, p.completed_flight_experience, p.completed_flight_cash_reward, p.completed_flight_cargo_reward, p.operation_type FROM player_planes pp JOIN planes p ON pp.plane_id = p.id WHERE pp.status = 'flying' AND DATE_ADD(pp.flight_start_time, INTERVAL p.travel_time_inSeconds SECOND) <= NOW() ` type GetPlanesReadyToLandRow struct { PlayerPlaneID uint32 `json:"player_plane_id"` AirportID uint32 `json:"airport_id"` AssignedHangarID uint32 `json:"assigned_hangar_id"` CompletedFlightExperience uint32 `json:"completed_flight_experience"` CompletedFlightCashReward sql.NullInt32 `json:"completed_flight_cash_reward"` CompletedFlightCargoReward sql.NullInt32 `json:"completed_flight_cargo_reward"` OperationType PlanesOperationType `json:"operation_type"` } // ============================================================================ // 6. TIME-BASED FLIGHT ENGINE // ============================================================================ func (q *Queries) GetPlanesReadyToLand(ctx context.Context) ([]GetPlanesReadyToLandRow, error) { rows, err := q.db.QueryContext(ctx, GetPlanesReadyToLand) if err != nil { return nil, err } defer rows.Close() items := []GetPlanesReadyToLandRow{} for rows.Next() { var i GetPlanesReadyToLandRow if err := rows.Scan( &i.PlayerPlaneID, &i.AirportID, &i.AssignedHangarID, &i.CompletedFlightExperience, &i.CompletedFlightCashReward, &i.CompletedFlightCargoReward, &i.OperationType, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const GetPlanesReadyToLandByUsername = `-- name: GetPlanesReadyToLandByUsername :many SELECT pp.id AS player_plane_id, pp.airport_id, pp.assigned_hangar_id, p.completed_flight_experience, p.completed_flight_cash_reward, p.completed_flight_cargo_reward, p.operation_type FROM player_planes pp JOIN planes p ON pp.plane_id = p.id WHERE pp.status = 'flying' AND DATE_ADD(pp.flight_start_time, INTERVAL p.travel_time_inSeconds SECOND) <= NOW() AND pp.airport_id = (select id from airports where user_id = (select id from users where username = ?)) ` type GetPlanesReadyToLandByUsernameRow struct { PlayerPlaneID uint32 `json:"player_plane_id"` AirportID uint32 `json:"airport_id"` AssignedHangarID uint32 `json:"assigned_hangar_id"` CompletedFlightExperience uint32 `json:"completed_flight_experience"` CompletedFlightCashReward sql.NullInt32 `json:"completed_flight_cash_reward"` CompletedFlightCargoReward sql.NullInt32 `json:"completed_flight_cargo_reward"` OperationType PlanesOperationType `json:"operation_type"` } // specific runway func (q *Queries) GetPlanesReadyToLandByUsername(ctx context.Context, username string) ([]GetPlanesReadyToLandByUsernameRow, error) { rows, err := q.db.QueryContext(ctx, GetPlanesReadyToLandByUsername, username) if err != nil { return nil, err } defer rows.Close() items := []GetPlanesReadyToLandByUsernameRow{} for rows.Next() { var i GetPlanesReadyToLandByUsernameRow if err := rows.Scan( &i.PlayerPlaneID, &i.AirportID, &i.AssignedHangarID, &i.CompletedFlightExperience, &i.CompletedFlightCashReward, &i.CompletedFlightCargoReward, &i.OperationType, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const GetPlayerFleet = `-- name: GetPlayerFleet :many SELECT pp.id AS player_plane_id, pp.status, pp.updated_at, pp.flight_start_time, pp.current_building_id, pp.assigned_hangar_id,p.id, p.name, p.min_level, p.operation_cost_fuel, p.operation_cost_cash, p.max_passengers, p.travel_time_inseconds, p.operation_type, p.aircraft_size, p.aircraft_type, p.buying_cost_cash, p.completed_flight_experience, p.completed_flight_cash_reward, p.completed_flight_cargo_reward FROM player_planes pp JOIN planes p ON pp.plane_id = p.id WHERE pp.airport_id = ? ` type GetPlayerFleetRow struct { PlayerPlaneID uint32 `json:"player_plane_id"` Status PlayerPlanesStatus `json:"status"` UpdatedAt sql.NullTime `json:"updated_at"` FlightStartTime sql.NullTime `json:"flight_start_time"` CurrentBuildingID sql.NullInt32 `json:"current_building_id"` AssignedHangarID uint32 `json:"assigned_hangar_id"` 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"` } func (q *Queries) GetPlayerFleet(ctx context.Context, airportID uint32) ([]GetPlayerFleetRow, error) { rows, err := q.db.QueryContext(ctx, GetPlayerFleet, airportID) if err != nil { return nil, err } defer rows.Close() items := []GetPlayerFleetRow{} for rows.Next() { var i GetPlayerFleetRow if err := rows.Scan( &i.PlayerPlaneID, &i.Status, &i.UpdatedAt, &i.FlightStartTime, &i.CurrentBuildingID, &i.AssignedHangarID, &i.ID, &i.Name, &i.MinLevel, &i.OperationCostFuel, &i.OperationCostCash, &i.MaxPassengers, &i.TravelTimeInseconds, &i.OperationType, &i.AircraftSize, &i.AircraftType, &i.BuyingCostCash, &i.CompletedFlightExperience, &i.CompletedFlightCashReward, &i.CompletedFlightCargoReward, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const GetPlayerPlanesByUsername = `-- name: GetPlayerPlanesByUsername :many SELECT pp.id AS player_plane_id, pp.id, pp.airport_id, pp.plane_id, pp.assigned_hangar_id, pp.current_building_id, pp.status, pp.updated_at, pp.flight_start_time FROM player_planes pp JOIN planes p ON pp.plane_id = p.id WHERE pp.airport_id = (select id from airports where user_id = (select id from users where username = ?)) ` type GetPlayerPlanesByUsernameRow struct { PlayerPlaneID uint32 `json:"player_plane_id"` 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"` } func (q *Queries) GetPlayerPlanesByUsername(ctx context.Context, username string) ([]GetPlayerPlanesByUsernameRow, error) { rows, err := q.db.QueryContext(ctx, GetPlayerPlanesByUsername, username) if err != nil { return nil, err } defer rows.Close() items := []GetPlayerPlanesByUsernameRow{} for rows.Next() { var i GetPlayerPlanesByUsernameRow if err := rows.Scan( &i.PlayerPlaneID, &i.ID, &i.AirportID, &i.PlaneID, &i.AssignedHangarID, &i.CurrentBuildingID, &i.Status, &i.UpdatedAt, &i.FlightStartTime, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const GetProductById = `-- name: GetProductById :one select id, name from products where id = ? ` func (q *Queries) GetProductById(ctx context.Context, id uint16) (Product, error) { row := q.db.QueryRowContext(ctx, GetProductById, id) var i Product err := row.Scan(&i.ID, &i.Name) return i, err } const GetUserByUsername = `-- name: GetUserByUsername :one SELECT id, username, password_hash FROM users WHERE username = ? LIMIT 1 ` type GetUserByUsernameRow struct { ID int32 `json:"id"` Username string `json:"username"` PasswordHash string `json:"password_hash"` } func (q *Queries) GetUserByUsername(ctx context.Context, username string) (GetUserByUsernameRow, error) { row := q.db.QueryRowContext(ctx, GetUserByUsername, username) var i GetUserByUsernameRow err := row.Scan(&i.ID, &i.Username, &i.PasswordHash) return i, err } const GetUserIdByUsername = `-- name: GetUserIdByUsername :one SELECT id FROM users WHERE username = ? LIMIT 1 ` func (q *Queries) GetUserIdByUsername(ctx context.Context, username string) (int32, error) { row := q.db.QueryRowContext(ctx, GetUserIdByUsername, username) var id int32 err := row.Scan(&id) return id, err } const LogCompletedFlightRoute = `-- name: LogCompletedFlightRoute :exec INSERT INTO completed_flight_routes_log (origin_airport_id, destination_airport_id, start_time, end_time) VALUES (?, ?, ?, NOW()) ` type LogCompletedFlightRouteParams struct { OriginAirportID uint32 `json:"origin_airport_id"` DestinationAirportID uint32 `json:"destination_airport_id"` StartTime time.Time `json:"start_time"` } func (q *Queries) LogCompletedFlightRoute(ctx context.Context, arg LogCompletedFlightRouteParams) error { _, err := q.db.ExecContext(ctx, LogCompletedFlightRoute, arg.OriginAirportID, arg.DestinationAirportID, arg.StartTime) return err } const LogCurrencyTransaction = `-- name: LogCurrencyTransaction :exec INSERT INTO currency_transaction_logs (airport_id, amount_changed, currency_type, reason) VALUES (?, ?, ?, ?) ` type LogCurrencyTransactionParams struct { AirportID uint32 `json:"airport_id"` AmountChanged int32 `json:"amount_changed"` CurrencyType CurrencyTransactionLogsCurrencyType `json:"currency_type"` Reason string `json:"reason"` } func (q *Queries) LogCurrencyTransaction(ctx context.Context, arg LogCurrencyTransactionParams) error { _, err := q.db.ExecContext(ctx, LogCurrencyTransaction, arg.AirportID, arg.AmountChanged, arg.CurrencyType, arg.Reason, ) return err } const UpdateAirportCash = `-- name: UpdateAirportCash :exec UPDATE airports SET cash = ? WHERE id = ? ` type UpdateAirportCashParams struct { Cash uint64 `json:"cash"` ID uint32 `json:"id"` } func (q *Queries) UpdateAirportCash(ctx context.Context, arg UpdateAirportCashParams) error { _, err := q.db.ExecContext(ctx, UpdateAirportCash, arg.Cash, arg.ID) return err } const UpdateAirportCurrencies = `-- name: UpdateAirportCurrencies :exec UPDATE airports SET cash = ?, current_passengers = ?, current_fuel = ? WHERE id = ? ` type UpdateAirportCurrenciesParams struct { Cash uint64 `json:"cash"` CurrentPassengers uint32 `json:"current_passengers"` CurrentFuel uint32 `json:"current_fuel"` ID uint32 `json:"id"` } // airport resource management func (q *Queries) UpdateAirportCurrencies(ctx context.Context, arg UpdateAirportCurrenciesParams) error { _, err := q.db.ExecContext(ctx, UpdateAirportCurrencies, arg.Cash, arg.CurrentPassengers, arg.CurrentFuel, arg.ID, ) return err } const UpdateAirportFuel = `-- name: UpdateAirportFuel :exec UPDATE airports SET current_fuel = ? WHERE id = ? ` type UpdateAirportFuelParams struct { CurrentFuel uint32 `json:"current_fuel"` ID uint32 `json:"id"` } func (q *Queries) UpdateAirportFuel(ctx context.Context, arg UpdateAirportFuelParams) error { _, err := q.db.ExecContext(ctx, UpdateAirportFuel, arg.CurrentFuel, arg.ID) return err } const UpdateAirportFuelRate = `-- name: UpdateAirportFuelRate :exec UPDATE airports SET fuel_generation_rate = ? WHERE id = ? ` type UpdateAirportFuelRateParams struct { FuelGenerationRate uint32 `json:"fuel_generation_rate"` ID uint32 `json:"id"` } func (q *Queries) UpdateAirportFuelRate(ctx context.Context, arg UpdateAirportFuelRateParams) error { _, err := q.db.ExecContext(ctx, UpdateAirportFuelRate, arg.FuelGenerationRate, arg.ID) return err } const UpdateAirportMaxFuel = `-- name: UpdateAirportMaxFuel :exec UPDATE airports SET max_fuel_capacity = ? WHERE id = ? ` type UpdateAirportMaxFuelParams struct { MaxFuelCapacity uint32 `json:"max_fuel_capacity"` ID uint32 `json:"id"` } func (q *Queries) UpdateAirportMaxFuel(ctx context.Context, arg UpdateAirportMaxFuelParams) error { _, err := q.db.ExecContext(ctx, UpdateAirportMaxFuel, arg.MaxFuelCapacity, arg.ID) return err } const UpdateAirportPassengerRate = `-- name: UpdateAirportPassengerRate :exec UPDATE airports SET passenger_generation_rate = ? WHERE id = ? ` type UpdateAirportPassengerRateParams struct { PassengerGenerationRate uint32 `json:"passenger_generation_rate"` ID uint32 `json:"id"` } func (q *Queries) UpdateAirportPassengerRate(ctx context.Context, arg UpdateAirportPassengerRateParams) error { _, err := q.db.ExecContext(ctx, UpdateAirportPassengerRate, arg.PassengerGenerationRate, arg.ID) return err } const UpdateAirportResources = `-- name: UpdateAirportResources :exec UPDATE airports SET current_fuel = LEAST( max_fuel_capacity, current_fuel + (fuel_generation_rate * (TIMESTAMPDIFF(SECOND, resources_last_updated_at, NOW()) DIV 60)) ), current_passengers = LEAST( max_passenger_capacity, current_passengers + (passenger_generation_rate * (TIMESTAMPDIFF(SECOND, resources_last_updated_at, NOW()) DIV 60)) ), resources_last_updated_at = resources_last_updated_at + INTERVAL (TIMESTAMPDIFF(SECOND, resources_last_updated_at, NOW()) DIV 60) MINUTE WHERE id = ? ` func (q *Queries) UpdateAirportResources(ctx context.Context, id uint32) error { _, err := q.db.ExecContext(ctx, UpdateAirportResources, id) return err } const UpdateAirportResourcesUpdated = `-- name: UpdateAirportResourcesUpdated :exec update airports set resources_last_updated_at = ? where id = ? ` type UpdateAirportResourcesUpdatedParams struct { ResourcesLastUpdatedAt time.Time `json:"resources_last_updated_at"` ID uint32 `json:"id"` } func (q *Queries) UpdateAirportResourcesUpdated(ctx context.Context, arg UpdateAirportResourcesUpdatedParams) error { _, err := q.db.ExecContext(ctx, UpdateAirportResourcesUpdated, arg.ResourcesLastUpdatedAt, arg.ID) return err } const UpdateAirportmaxPassengers = `-- name: UpdateAirportmaxPassengers :exec UPDATE airports SET max_passenger_capacity = ? WHERE id = ? ` type UpdateAirportmaxPassengersParams struct { MaxPassengerCapacity uint32 `json:"max_passenger_capacity"` ID uint32 `json:"id"` } func (q *Queries) UpdateAirportmaxPassengers(ctx context.Context, arg UpdateAirportmaxPassengersParams) error { _, err := q.db.ExecContext(ctx, UpdateAirportmaxPassengers, arg.MaxPassengerCapacity, arg.ID) return err } const UpdateAirportpassengers = `-- name: UpdateAirportpassengers :exec UPDATE airports SET current_passengers = ? WHERE id = ? ` type UpdateAirportpassengersParams struct { CurrentPassengers uint32 `json:"current_passengers"` ID uint32 `json:"id"` } func (q *Queries) UpdateAirportpassengers(ctx context.Context, arg UpdateAirportpassengersParams) error { _, err := q.db.ExecContext(ctx, UpdateAirportpassengers, arg.CurrentPassengers, arg.ID) return err } const UpdateContractDelivery = `-- name: UpdateContractDelivery :exec UPDATE airport_contracts SET current_amount_delivered = current_amount_delivered + ? WHERE id = ? AND is_completed = FALSE ` type UpdateContractDeliveryParams struct { CurrentAmountDelivered uint32 `json:"current_amount_delivered"` ID uint32 `json:"id"` } func (q *Queries) UpdateContractDelivery(ctx context.Context, arg UpdateContractDeliveryParams) error { _, err := q.db.ExecContext(ctx, UpdateContractDelivery, arg.CurrentAmountDelivered, arg.ID) return err } const UpdatePlaneState = `-- name: UpdatePlaneState :exec UPDATE player_planes SET current_building_id = ?, status = ?, flight_start_time = ? WHERE id = ? ` type UpdatePlaneStateParams struct { CurrentBuildingID sql.NullInt32 `json:"current_building_id"` Status PlayerPlanesStatus `json:"status"` FlightStartTime sql.NullTime `json:"flight_start_time"` ID uint32 `json:"id"` } func (q *Queries) UpdatePlaneState(ctx context.Context, arg UpdatePlaneStateParams) error { _, err := q.db.ExecContext(ctx, UpdatePlaneState, arg.CurrentBuildingID, arg.Status, arg.FlightStartTime, arg.ID, ) return err } const UpdatePlayerPlaneState = `-- name: UpdatePlayerPlaneState :exec UPDATE player_planes SET current_building_id = ?, status = ?, flight_start_time = ? WHERE id = ? ` type UpdatePlayerPlaneStateParams struct { CurrentBuildingID sql.NullInt32 `json:"current_building_id"` Status PlayerPlanesStatus `json:"status"` FlightStartTime sql.NullTime `json:"flight_start_time"` ID uint32 `json:"id"` } func (q *Queries) UpdatePlayerPlaneState(ctx context.Context, arg UpdatePlayerPlaneStateParams) error { _, err := q.db.ExecContext(ctx, UpdatePlayerPlaneState, arg.CurrentBuildingID, arg.Status, arg.FlightStartTime, arg.ID, ) return err } const UpdateUserPasswordByUserName = `-- name: UpdateUserPasswordByUserName :exec UPDATE users SET password_hash = ? WHERE username = ? ` type UpdateUserPasswordByUserNameParams struct { PasswordHash string `json:"password_hash"` Username string `json:"username"` } func (q *Queries) UpdateUserPasswordByUserName(ctx context.Context, arg UpdateUserPasswordByUserNameParams) error { _, err := q.db.ExecContext(ctx, UpdateUserPasswordByUserName, arg.PasswordHash, arg.Username) return err } const AddBuilding = `-- name: addBuilding :execresult INSERT INTO buildings (name,min_level,construction_cost_cash) VALUES (?, ?, ?) ` type addBuildingParams struct { Name string `json:"name"` MinLevel uint32 `json:"min_level"` ConstructionCostCash uint32 `json:"construction_cost_cash"` } func (q *Queries) addBuilding(ctx context.Context, arg addBuildingParams) (sql.Result, error) { return q.db.ExecContext(ctx, AddBuilding, arg.Name, arg.MinLevel, arg.ConstructionCostCash) } const AddOperationalBuilding = `-- name: addOperationalBuilding :execresult INSERT INTO buildings (name,min_level,construction_cost_cash,operation_type,operation_size) VALUES (?, ?, ?, ?, ?) ` type addOperationalBuildingParams struct { Name string `json:"name"` MinLevel uint32 `json:"min_level"` ConstructionCostCash uint32 `json:"construction_cost_cash"` OperationType NullBuildingsOperationType `json:"operation_type"` OperationSize NullBuildingsOperationSize `json:"operation_size"` } func (q *Queries) addOperationalBuilding(ctx context.Context, arg addOperationalBuildingParams) (sql.Result, error) { return q.db.ExecContext(ctx, AddOperationalBuilding, arg.Name, arg.MinLevel, arg.ConstructionCostCash, arg.OperationType, arg.OperationSize, ) } const AddPassiveProductionBuilding = `-- name: addPassiveProductionBuilding :execresult INSERT INTO buildings (name,min_level,construction_cost_cash,passive_type,passive_rate) VALUES (?, ?, ?, ?, ?) ` type addPassiveProductionBuildingParams struct { Name string `json:"name"` MinLevel uint32 `json:"min_level"` ConstructionCostCash uint32 `json:"construction_cost_cash"` PassiveType NullBuildingsPassiveType `json:"passive_type"` PassiveRate sql.NullInt32 `json:"passive_rate"` } func (q *Queries) addPassiveProductionBuilding(ctx context.Context, arg addPassiveProductionBuildingParams) (sql.Result, error) { return q.db.ExecContext(ctx, AddPassiveProductionBuilding, arg.Name, arg.MinLevel, arg.ConstructionCostCash, arg.PassiveType, arg.PassiveRate, ) } const AddPlane = `-- name: addPlane :execresult 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) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ` type addPlaneParams struct { Name string `json:"name"` AircraftSize PlanesAircraftSize `json:"aircraft_size"` OperationType PlanesOperationType `json:"operation_type"` AircraftType PlanesAircraftType `json:"aircraft_type"` 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"` 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"` } // planes & fleet management func (q *Queries) addPlane(ctx context.Context, arg addPlaneParams) (sql.Result, error) { return q.db.ExecContext(ctx, AddPlane, arg.Name, arg.AircraftSize, arg.OperationType, arg.AircraftType, arg.MinLevel, arg.OperationCostFuel, arg.OperationCostCash, arg.MaxPassengers, arg.TravelTimeInseconds, arg.BuyingCostCash, arg.CompletedFlightExperience, arg.CompletedFlightCashReward, arg.CompletedFlightCargoReward, ) } const AddPlaneToAirportByUsername = `-- name: addPlaneToAirportByUsername :execresult INSERT INTO player_planes (airport_id, plane_id, assigned_hangar_id, current_building_id, status) VALUES ((select id from airports where user_id = (select id from users where username = ?)), ?, ?, ?, 'idle') ` type addPlaneToAirportByUsernameParams struct { Username string `json:"username"` PlaneID uint32 `json:"plane_id"` AssignedHangarID uint32 `json:"assigned_hangar_id"` CurrentBuildingID sql.NullInt32 `json:"current_building_id"` } func (q *Queries) addPlaneToAirportByUsername(ctx context.Context, arg addPlaneToAirportByUsernameParams) (sql.Result, error) { return q.db.ExecContext(ctx, AddPlaneToAirportByUsername, arg.Username, arg.PlaneID, arg.AssignedHangarID, arg.CurrentBuildingID, ) } const AddStorageBuilding = `-- name: addStorageBuilding :execresult INSERT INTO buildings (name,min_level,construction_cost_cash,capacity,storage_type,storage_subtype) VALUES (?, ?, ?, ?, ?, ?) ` type addStorageBuildingParams struct { Name string `json:"name"` MinLevel uint32 `json:"min_level"` ConstructionCostCash uint32 `json:"construction_cost_cash"` Capacity sql.NullInt32 `json:"capacity"` StorageType NullBuildingsStorageType `json:"storage_type"` StorageSubtype NullBuildingsStorageSubtype `json:"storage_subtype"` } func (q *Queries) addStorageBuilding(ctx context.Context, arg addStorageBuildingParams) (sql.Result, error) { return q.db.ExecContext(ctx, AddStorageBuilding, arg.Name, arg.MinLevel, arg.ConstructionCostCash, arg.Capacity, arg.StorageType, arg.StorageSubtype, ) } const UpdatePlayerExperience = `-- name: updatePlayerExperience :exec UPDATE airports SET experience_points = ? WHERE id = ? ` type updatePlayerExperienceParams struct { ExperiencePoints uint64 `json:"experience_points"` ID uint32 `json:"id"` } func (q *Queries) updatePlayerExperience(ctx context.Context, arg updatePlayerExperienceParams) error { _, err := q.db.ExecContext(ctx, UpdatePlayerExperience, arg.ExperiencePoints, arg.ID) return err } const UpdatePlayerLevel = `-- name: updatePlayerLevel :exec UPDATE airports SET player_level = ? WHERE id = ? ` type updatePlayerLevelParams struct { PlayerLevel uint32 `json:"player_level"` ID uint32 `json:"id"` } func (q *Queries) updatePlayerLevel(ctx context.Context, arg updatePlayerLevelParams) error { _, err := q.db.ExecContext(ctx, UpdatePlayerLevel, arg.PlayerLevel, arg.ID) return err }