adnan is born

This commit is contained in:
portakal 2026-05-25 22:29:21 +03:00
commit 76e4f763b6
3 changed files with 228 additions and 11 deletions

View file

@ -25,6 +25,41 @@ func (q *Queries) AddBuildingToAirportByUsername(ctx context.Context, arg AddBui
return q.db.ExecContext(ctx, addBuildingToAirportByUsername, arg.Username, arg.BuildingID)
}
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
Continent CountriesContinent
Produce1ID uint16
Produce2ID uint16
Produce3ID uint16
}
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 addproduct = `-- name: Addproduct :execresult
insert into products (name) values (?)
`
// ============================================================================
// 4. BUILDINGS & PRODUCTION ENGINE
// ============================================================================
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)
@ -447,6 +482,41 @@ func (q *Queries) GetAirportByUserName(ctx context.Context, username string) (Ge
return i, err
}
const getAllCountries = `-- name: GetAllCountries :many
SELECT id, name FROM countries
`
type GetAllCountriesRow struct {
ID uint16
Name string
}
// ============================================================================
// 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()
var 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
`
@ -489,6 +559,65 @@ func (q *Queries) GetAllPlanes(ctx context.Context) ([]Plane, error) {
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()
var 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
Name string
}
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
Name string
}
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 = ?
`
@ -917,6 +1046,17 @@ func (q *Queries) GetPlayerPlanesByUsername(ctx context.Context, username string
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
@ -1370,9 +1510,6 @@ func (q *Queries) addPlaneToAirportByUsername(ctx context.Context, arg addPlaneT
}
const addStorageBuilding = `-- name: addStorageBuilding :execresult
INSERT INTO buildings (name,min_level,construction_cost_cash,capacity,storage_type,storage_subtype)
VALUES (?, ?, ?, ?, ?, ?)
`
@ -1386,12 +1523,6 @@ type addStorageBuildingParams struct {
StorageSubtype NullBuildingsStorageSubtype
}
// ============================================================================
// 3. WAREHOUSE & INVENTORY SYSTEM
// ============================================================================
// ============================================================================
// 4. BUILDINGS & PRODUCTION ENGINE
// ============================================================================
func (q *Queries) addStorageBuilding(ctx context.Context, arg addStorageBuildingParams) (sql.Result, error) {
return q.db.ExecContext(ctx, addStorageBuilding,
arg.Name,