bereich.png erstellt und bei editMode active marker.setZIndexOffset(1000);

This commit is contained in:
ISA
2024-12-20 08:10:45 +01:00
parent 2adca70ba5
commit 38b43cbe48
6 changed files with 148 additions and 2 deletions

View File

@@ -0,0 +1,34 @@
import getPool from "../../../utils/mysqlPool"; // Singleton-Pool importieren
export default async function handler(req, res) {
const pool = getPool(); // Singleton-Pool verwenden
if (req.method !== "PUT") {
return res.status(405).json({ error: "Nur PUT Methode erlaubt" });
}
const { idLocation, idMap, x, y } = req.body;
if (!idLocation || !idMap || x === undefined || y === undefined) {
return res.status(400).json({ error: "Alle Felder (idLocation, idMap, x, y) sind erforderlich" });
}
let connection;
try {
connection = await pool.getConnection();
const query = "UPDATE location_coordinates SET x = ?, y = ? WHERE idLocation = ? AND idMaps = ?";
const [result] = await connection.query(query, [x, y, idLocation, idMap]);
if (result.affectedRows > 0) {
res.status(200).json({ success: true, message: "Koordinaten erfolgreich aktualisiert" });
} else {
res.status(404).json({ error: "Kein Eintrag gefunden, der aktualisiert werden konnte" });
}
} catch (error) {
console.error("Fehler beim Aktualisieren der Koordinaten:", error);
res.status(500).json({ error: "Interner Serverfehler beim Aktualisieren der Koordinaten" });
} finally {
if (connection) connection.release();
}
}