finish world initialization, set up init on startup and on shutdown, move all models to main directory

This commit is contained in:
lbenedar
2026-04-24 18:04:35 +03:00
parent 07025afefc
commit fd65631be1
125 changed files with 1534 additions and 2802 deletions

View File

@@ -1,37 +1,22 @@
package main
import (
"encoding/json"
"fmt"
"net/http"
"time"
"gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/temp_models/db"
"gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
)
func (app *application) ShowText(w http.ResponseWriter, r *http.Request) {
data, err := app.foundryApp.Test()
dbConn := app.foundryApp.Transport.DB
world, err := db.GetWorld(dbConn, "kingmaker")
if err != nil {
app.slogger.Error("", "error", err)
w.Write([]byte(err.Error()))
w.Write([]byte("Got error"))
return
}
var dbGame db.Game
start := time.Now()
data.ToDB(&dbGame)
elapsed := time.Since(start)
app.slogger.Info("Game data successfully parsed", "elapsedtime", elapsed)
byteData, err := json.Marshal(data)
if err != nil {
app.slogger.Error("", "error", err)
w.Write([]byte(err.Error()))
return
}
w.Write(byteData)
w.Write([]byte(fmt.Sprintf("Got world with name %s, core_version - %s, next_session - %v", world.ID, world.CoreVersion, world.NextSession)))
}
func (app *application) WhenNextSession(w http.ResponseWriter, r *http.Request) {