2025-05-19 16:25:20 +02:00
|
|
|
import { db } from "$lib/server/db";
|
|
|
|
import * as table from "$lib/server/db/schema";
|
2025-05-19 16:40:11 +02:00
|
|
|
import { eq } from "drizzle-orm";
|
2025-05-19 16:25:20 +02:00
|
|
|
import type { PageServerLoad } from "./$types";
|
|
|
|
|
|
|
|
export const load: PageServerLoad = async ({ params }) => {
|
|
|
|
{
|
2025-05-19 16:40:11 +02:00
|
|
|
const floor_cnt = await db.select({ floor: table.plans.floor, json: table.plans.plan }).from(table.plans).where(eq(table.plans.floor, params.slug));
|
|
|
|
if (floor_cnt.length == 0) {
|
|
|
|
await db.insert(table.plans).values({ floor: params.slug, plan: {
|
|
|
|
"regions": [
|
|
|
|
{ "start": { "x": 100, "y": 100 }, "end": { "x": 400, "y": 100 } },
|
|
|
|
{ "start": { "x": 400, "y": 100 }, "end": { "x": 400, "y": 300 } },
|
|
|
|
{ "start": { "x": 400, "y": 300 }, "end": { "x": 100, "y": 300 } },
|
|
|
|
{ "start": { "x": 100, "y": 300 }, "end": { "x": 100, "y": 100 } }
|
|
|
|
],
|
|
|
|
"doors": [
|
|
|
|
{ "location": { "x": 240, "y": 100 }, "width": 50, "rotation": 0 }
|
|
|
|
],
|
|
|
|
"furnitures": [
|
|
|
|
{
|
|
|
|
"minBound": { "x": 150, "y": 150 },
|
|
|
|
"maxBound": { "x": 200, "y": 200 },
|
|
|
|
"equipName": "Table",
|
|
|
|
"xPlacement": 150,
|
|
|
|
"yPlacement": 150,
|
|
|
|
"rotation": 0
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}});
|
2025-05-19 16:25:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2025-05-19 16:40:11 +02:00
|
|
|
const floor_ = await db.select({ floor: table.plans.floor, json: table.plans.plan }).from(table.plans).where(eq(table.plans.floor, params.slug));
|
|
|
|
return { slug: params.slug, floor: floor_ };
|
2025-05-19 16:25:20 +02:00
|
|
|
};
|