polylines tooltip content
This commit is contained in:
@@ -1,53 +1,45 @@
|
||||
// pages/api/talas_v5_DB/pois/updatePoi.js
|
||||
import mysql from "mysql";
|
||||
import mysql from "mysql2/promise";
|
||||
|
||||
const dbConfig = {
|
||||
// Erstellen eines Pools von Datenbankverbindungen
|
||||
const pool = mysql.createPool({
|
||||
host: process.env.DB_HOST,
|
||||
user: process.env.DB_USER,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_NAME,
|
||||
port: process.env.DB_PORT,
|
||||
};
|
||||
|
||||
const connection = mysql.createConnection(dbConfig);
|
||||
connection.connect((err) => {
|
||||
if (err) {
|
||||
console.error("Fehler beim Verbinden:", err.stack);
|
||||
return;
|
||||
}
|
||||
console.log("Verbunden als ID", connection.threadId);
|
||||
waitForConnections: true,
|
||||
connectionLimit: 10,
|
||||
queueLimit: 0,
|
||||
});
|
||||
|
||||
export default function handler(req, res) {
|
||||
export default async function handler(req, res) {
|
||||
if (req.method !== "POST") {
|
||||
return res.status(405).json({ error: "Nur POST Methode erlaubt" });
|
||||
}
|
||||
|
||||
const { idPoi, description, idPoiTyp, idLD } = req.body; // Stellen Sie sicher, dass die Felder korrekt benannt sind
|
||||
|
||||
console.log("Empfangene Daten:", req.body); // Loggen der empfangenen Daten zur Überprüfung
|
||||
const { idPoi, description, idPoiTyp, idLD } = req.body;
|
||||
|
||||
if (!idPoi) {
|
||||
return res.status(400).json({ error: "POI ID ist erforderlich" });
|
||||
}
|
||||
|
||||
const query =
|
||||
"UPDATE talas_v5.poi SET description = ?, idPoiTyp = ?, idLD = ? WHERE idPoi = ?";
|
||||
connection.query(
|
||||
query,
|
||||
[description, idPoiTyp, idLD, idPoi],
|
||||
(error, results) => {
|
||||
if (error) {
|
||||
console.error("Fehler beim Aktualisieren des POI:", error);
|
||||
return res
|
||||
.status(500)
|
||||
.json({ error: "Fehler beim Aktualisieren des POI" });
|
||||
}
|
||||
if (results.affectedRows > 0) {
|
||||
res.json({ message: "POI erfolgreich aktualisiert" });
|
||||
} else {
|
||||
res.status(404).json({ error: "POI nicht gefunden" });
|
||||
}
|
||||
const query = `
|
||||
UPDATE talas_v5.poi
|
||||
SET description = ?, idPoiTyp = ?, idLD = ?
|
||||
WHERE idPoi = ?
|
||||
`;
|
||||
|
||||
try {
|
||||
const [results] = await pool.query(query, [description, idPoiTyp, idLD, idPoi]);
|
||||
|
||||
if (results.affectedRows > 0) {
|
||||
res.status(200).json({ message: "POI erfolgreich aktualisiert" });
|
||||
} else {
|
||||
res.status(404).json({ error: "POI nicht gefunden" });
|
||||
}
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Fehler beim Aktualisieren des POI:", error);
|
||||
res.status(500).json({ error: "Fehler beim Aktualisieren des POI" });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user