add: priorityConfig API-Endpoint for priority on the map ,if there overlapping , level 0 has high priority
This commit is contained in:
43
pages/api/talas_v5_DB/priorityConfig.js
Normal file
43
pages/api/talas_v5_DB/priorityConfig.js
Normal file
@@ -0,0 +1,43 @@
|
||||
// pages/api/talas_v5_DB/priorityConfig.js
|
||||
// in tals5 http://10.10.0.13/talas5/Management/PriorityConfig.aspx beinhaltet die Tabelle prio die Prioritäten der Meldungen (Level 1-4) oder (0-4) je nachdem DB-Design
|
||||
// das ist die API, die die Prioritäten zurückgibt
|
||||
|
||||
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,
|
||||
};
|
||||
console.log("my dbconfig: ", dbConfig);
|
||||
export default function handler(req, res) {
|
||||
const connection = mysql.createConnection(dbConfig);
|
||||
|
||||
connection.connect((err) => {
|
||||
if (err) {
|
||||
console.error("Fehler beim Verbinden:", err.stack);
|
||||
res.status(500).json({ error: "Verbindungsfehler zur Datenbank" });
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("Verbunden als ID", connection.threadId);
|
||||
//Fehler weil, existiertdie Tabelle auf localhost:3000 nicht
|
||||
connection.query(
|
||||
"SELECT idprio, level, name, color FROM prio ",
|
||||
(error, results) => {
|
||||
if (error) {
|
||||
console.error("Fehler beim Abrufen der API", error);
|
||||
res.status(500).json({ error: "Fehler bei der Abfrage" });
|
||||
return;
|
||||
}
|
||||
|
||||
// Wichtig: Senden Sie die Antwort zurück
|
||||
res.status(200).json(results);
|
||||
|
||||
connection.end();
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user