diff --git a/src/controllers/admincontroller.js b/src/controllers/admincontroller.js index 31399bd5..bc487095 100644 --- a/src/controllers/admincontroller.js +++ b/src/controllers/admincontroller.js @@ -6,7 +6,7 @@ const bcrypt = require('bcrypt') const fastify = require("fastify"); const { Tank, MotorData, IotData } = require('../models/tanks'); -const { Deparments } = require('../models/Department'); +const { Deparments, City } = require('../models/Department'); const JWT_SECRET = 'your-secret-key'; async function generateCustomerId(role) { @@ -422,3 +422,20 @@ exports.createUser = async (request, reply) => { }); } }; + + +exports.getAllCompanys = async (req, reply) => { + try { + const pendingOrders = await City.find(); + + + return reply.send({ + status_code: 200, + message: "Pending orders fetched successfully", + data: pendingOrders, + }); + } catch (err) { + console.error("Error fetching pending orders:", err); + return reply.status(500).send({ error: "Internal server error" }); + } +}; \ No newline at end of file diff --git a/src/routes/adminRoute.js b/src/routes/adminRoute.js index 94010257..288c2d3a 100644 --- a/src/routes/adminRoute.js +++ b/src/routes/adminRoute.js @@ -278,6 +278,16 @@ fastify.post("/api/getDepartmentDetails/:adminId", { handler: adminController.getDepartmentDetailsByAdminAndName }); +fastify.get("/api/getAllCompanies", { + schema: { + tags: ["Admin"], + description: "Get all Companies List", + summary: "Get all Companies List", + + }, + handler: adminController.getAllCompanys, +}); + next(); };