diff --git a/src/controllers/departmentController.js b/src/controllers/departmentController.js index 872833f6..45f0b488 100644 --- a/src/controllers/departmentController.js +++ b/src/controllers/departmentController.js @@ -1854,4 +1854,16 @@ exports.getCitiesBasedState = async (request, reply) => { }; - \ No newline at end of file + exports.getStaffDepartmentDetails = async (request, reply) => { + try { + const officeName = request.params.officeName; + const city = request.params.city; + const department = await Deparments.find({ officeName, city }); + if (!department) { + return reply.status(404).send({ message: 'Department not found' }); + } + reply.send({ department }); + } catch (err) { + reply.status(500).send({ message: err.message }); + } +}; \ No newline at end of file diff --git a/src/routes/departmentRoute.js b/src/routes/departmentRoute.js index 1794c16f..a948d45a 100644 --- a/src/routes/departmentRoute.js +++ b/src/routes/departmentRoute.js @@ -822,5 +822,24 @@ fastify.route({ }, handler:departmentController.getCitiesBasedState }); + +fastify.route({ + method: "GET", + url: "/api/staffdepartments/:officeName/:city", + schema: { + tags: ["Department"], + description: "This is for fetching department details based on officeName and city", + summary: "This is for fetching department details based on officeName and city", + params: { + type: "object", + properties: { + officeName: { type: "string" }, + city: { type: "string" } + } + } + }, + handler: departmentController.getStaffDepartmentDetails +}); + next(); }; \ No newline at end of file