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

@ -38,10 +38,66 @@ func update_user(queries *db.Queries, ctx context.Context, username string, pass
fmt.Printf("Error at operation : %v\n", err)
os.Exit(1)
}
fmt.Printf("updated user : %s with %s \n", username, string(hashed_pass))
fmt.Println("successfully updated user")
}
func add_airport(queries *db.Queries, ctx context.Context, airportName string, userName string, countryCode uint16) {
res, err := queries.CreateAirportByUserName(ctx, db.CreateAirportByUserNameParams{
Name: airportName,
Username: userName,
OriginCountryID: countryCode,
})
if err != nil {
fmt.Printf("Error at operation : %v\n", err)
os.Exit(1)
}
fmt.Println(res.LastInsertId())
fmt.Printf("added airport : %s ", airportName)
}
func add_products(queries *db.Queries, ctx context.Context, name string) {
res, err := queries.Addproduct(ctx, name)
if err != nil {
fmt.Printf("Error at operation : %v\n", err)
os.Exit(1)
}
fmt.Println(res.LastInsertId())
fmt.Printf("added product : %s ", name)
}
func add_country(queries *db.Queries, ctx context.Context, countryname string, continent db.CountriesContinent, produce_1, produce_2, produce_3 uint16) {
res, err := queries.AddCountry(ctx, db.AddCountryParams{
Name: countryname,
Continent: continent,
Produce1ID: produce_1,
Produce2ID: produce_2,
Produce3ID: produce_3,
})
if err != nil {
fmt.Printf("Error at operation : %v\n", err)
os.Exit(1)
}
fmt.Println(res.LastInsertId())
fmt.Printf("added country : %s ", countryname)
}
func get_country_byCountryName(queries *db.Queries, ctx context.Context, countryname string) db.GetCountryByNameRow {
res, err := queries.GetCountryByName(ctx, countryname)
if err != nil {
fmt.Printf("Error at operation : %v\n", err)
os.Exit(1)
}
fmt.Println(res)
fmt.Printf("added country : %s ", countryname)
return res
}
func main() {
dsn := "skyramaUser:Skyrama1234.@tcp(127.0.0.1:3306)/skyrama_clone?parseTime=true"
@ -57,6 +113,15 @@ func main() {
}
ctx := context.Background()
queries := db.New(dbConn)
create_user(queries, ctx, "tester_adnan", "a")
// user opps
//create_user(queries, ctx, "tester_adnan", "a")
//update_user(queries, ctx, "tester_adnan", "a")
//product
//add_products(queries, ctx, "nothing")
//airport opps
//add_country(queries, ctx, "void", db.CountriesContinentVoid, 0, 0, 0)
add_airport(queries, ctx, "adnan's AirPort", "tester_adnan", get_country_byCountryName(queries, ctx, "void").ID)
}