polylines tooltip content
This commit is contained in:
46
pages/api back30/talas_v5_DB/pois/updatePoi.js
Normal file
46
pages/api back30/talas_v5_DB/pois/updatePoi.js
Normal file
@@ -0,0 +1,46 @@
|
||||
// pages/api/talas_v5_DB/pois/updatePoi.js
|
||||
import mysql from "mysql";
|
||||
|
||||
const dbConfig = {
|
||||
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);
|
||||
});
|
||||
|
||||
export default 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
|
||||
|
||||
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" });
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user