var express = require("express");
const router = express.Router();
const db = require("../../utils/database");

router.get("/getSystems", (req, res) => {
  var status = req.query.status;
  var query = `select * from finehhdi_eDefect.SystemNames order by id desc`;
  db.getConnection((err, connection) => {
    if (err) {
      console.log("database not connected error: >>>", err);
      throw err;
    }
    console.log("get Connection");

    connection.query(query, (err, result) => {
      connection.release();
      if (err) {
        res.status(401).json({
          message: "Some error in type selection",
          results: "Failed",
          systemName: [],
        });
      } else {
        res.status(201).json({
          message: "type Successfully",
          results: "Success",
          systemName: result,
        });
      }
    });
    console.log("release Connection");
  });
});

module.exports = router;
