From 7d6c1a5544b4492d5a3268ec7f76ab7f51abb71f Mon Sep 17 00:00:00 2001 From: Bhaskar Date: Tue, 28 Jan 2025 14:31:34 +0530 Subject: [PATCH] locations list in admin --- src/controllers/departmentController.js | 11 +++++++++++ src/routes/departmentRoute.js | 17 +++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/controllers/departmentController.js b/src/controllers/departmentController.js index b3302718..87c40348 100644 --- a/src/controllers/departmentController.js +++ b/src/controllers/departmentController.js @@ -446,6 +446,17 @@ exports.addDepartment = async (request, reply) => { throw boom.boomify(err); } }; + + exports.getallLocationData = async (req, reply) => { + try { + console.log("Fetching all zones..."); // Debug log + const locations = await Deparments.distinct('location'); + reply.send({ status_code: 200, data: locations, count: locations.length }); + } catch (err) { + console.error("Error fetching cities:", err); // Log the error for debugging + throw boom.boomify(err); + } + }; exports.deletedepartmentInfo = async (req, reply) => { try { diff --git a/src/routes/departmentRoute.js b/src/routes/departmentRoute.js index 5b51b0fd..78328a01 100644 --- a/src/routes/departmentRoute.js +++ b/src/routes/departmentRoute.js @@ -266,6 +266,23 @@ module.exports = function (fastify, opts, next) { //preHandler: fastify.auth([fastify.authenticate]), handler: departmentController.getallZonesData, }); + + fastify.get("/api/getalllocationsdata", { + schema: { + tags: ["Department"], + description: "This is for Get all Locations Data", + summary: "This is for to Get all Locations Data", + + security: [ + { + basicAuth: [], + }, + ], + }, + //preHandler: fastify.auth([fastify.authenticate]), + handler: departmentController.getallLocationData, + }); + fastify.delete("/api/deletedepartment/:departmentId", { schema: { description: "Delete a Department by departmentId",