idLD foreign key von talas_v5.location_device in poi Tabelle ,in der Spalte idLD speichern beim hinzufügen eines POI auf die Map
This commit is contained in:
@@ -11,13 +11,14 @@ const dbConfig = {
|
||||
|
||||
export default function handler(req, res) {
|
||||
if (req.method === "POST") {
|
||||
const { name, poiTypeId, latitude, longitude } = req.body;
|
||||
const { name, poiTypeId, latitude, longitude, idLD } = req.body;
|
||||
console.log("Received data:", req.body); // Überprüfen der empfangenen Daten
|
||||
const connection = mysql.createConnection(dbConfig);
|
||||
|
||||
const query = "INSERT INTO poi (description, idPoiTyp, position) VALUES (?, ?, ST_GeomFromText(?))";
|
||||
const query =
|
||||
"INSERT INTO poi (description, idPoiTyp, position, idLD) VALUES (?, ?, ST_GeomFromText(?),?)";
|
||||
const point = `POINT(${longitude} ${latitude})`;
|
||||
const values = [name, poiTypeId, point]; // Stellen Sie sicher, dass poiTypeId korrekt ist
|
||||
const values = [name, poiTypeId, point, idLD]; // Stellen Sie sicher, dass poiTypeId korrekt ist
|
||||
|
||||
connection.query(query, values, (error, results) => {
|
||||
connection.end();
|
||||
@@ -25,11 +26,15 @@ export default function handler(req, res) {
|
||||
console.error("Fehler beim Einfügen des Standorts:", error);
|
||||
return res.status(500).json({ error: "Ein Fehler ist aufgetreten" });
|
||||
}
|
||||
res.status(200).json({ id: results.insertId, message: "Standort erfolgreich hinzugefügt" });
|
||||
res
|
||||
.status(200)
|
||||
.json({
|
||||
id: results.insertId,
|
||||
message: "Standort erfolgreich hinzugefügt",
|
||||
});
|
||||
});
|
||||
} else {
|
||||
res.setHeader("Allow", ["POST"]);
|
||||
res.status(405).end(`Method ${req.method} Not Allowed`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user