diff --git a/src/controllers/departmentController.js b/src/controllers/departmentController.js index e59ec445..9cb9afb7 100644 --- a/src/controllers/departmentController.js +++ b/src/controllers/departmentController.js @@ -605,6 +605,31 @@ exports.addDepartment = async (request, reply) => { } }; + exports.getCityDetails = async (request, reply) => { + try { + const cityId = request.params.cityId; + const data = await City.findOne({ cityId }); + if (!data) { + return reply.status(404).send({ message: 'City not found' }); + } + reply.send({ data }); + } catch (err) { + reply.status(500).send({ message: err.message }); + } +}; + +exports.getBranchDetails = async (request, reply) => { + try { + const branchId = request.params.branchId; + const data = await Branch.findOne({ branchId }); + if (!data) { + return reply.status(404).send({ message: 'Branch not found' }); + } + reply.send({ data }); + } catch (err) { + reply.status(500).send({ message: err.message }); + } +}; exports.getSinledepartmentData = async (req, reply) => { try { const { departmentId } = req.params; diff --git a/src/routes/departmentRoute.js b/src/routes/departmentRoute.js index c636a6fb..303cabcc 100644 --- a/src/routes/departmentRoute.js +++ b/src/routes/departmentRoute.js @@ -175,8 +175,38 @@ module.exports = function (fastify, opts, next) { }, handler: departmentController.editcity, }); - - +fastify.route({ + method: "GET", + url: "/api/city/:cityId", + schema: { + tags: ["Department"], + description: "This is for fetching a City details", + summary: "This is for fetching a City details", + params: { + type: "object", + properties: { + cityId: { type: "string" } + } + } + }, + handler: departmentController.getCityDetails +}); + fastify.route({ + method: "GET", + url: "/api/branch/:branchId", + schema: { + tags: ["Department"], + description: "This is for fetching a Branch details", + summary: "This is for fetching a Branch details", + params: { + type: "object", + properties: { + branchId: { type: "string" } + } + } + }, + handler: departmentController.getBranchDetails +}); fastify.route({ method: "POST", url: "/api/departmentSignup",