WIP: noch Design für POI hinzufügen

This commit is contained in:
ISA
2024-09-17 12:35:52 +02:00
parent 941ab2276b
commit 132242e7d8
5 changed files with 105 additions and 57 deletions

View File

@@ -7,26 +7,27 @@ export default async function handler(req, res) {
let connection;
try {
// SQL-Query and parameters
const sql = "SELECT idLD, iddevice, name FROM location_device ORDER BY name";
//const params = [160]; // Example parameter
// SQL-Query, um die Geräteinformationen aus location_device und devices zu erhalten
const sql = `
SELECT ld.idLD, ld.iddevice, ld.name, d.idsystem_typ
FROM location_device ld
JOIN devices d ON ld.iddevice = d.iddevice
ORDER BY ld.name
`;
// Get a connection from the pool
connection = await pool.getConnection();
// Execute the query
//const [results] = await connection.query(sql, params);
// Führe die Abfrage durch
const [results] = await connection.query(sql);
// Check if results are empty
if (!results.length) {
return res.status(404).json({ error: "Keine Geräte gefunden" });
}
// Respond with the results
// Geben Sie die Daten zurück
res.status(200).json(results);
} catch (error) {
// Log and return error
// Loggen Sie den Fehler und geben Sie ihn zurück
console.error("Fehler beim Abrufen der Geräteinformationen:", error);
res.status(500).json({ error: "Fehler beim Abrufen der Geräteinformationen" });
} finally {