ashok 2 months ago
commit bfef9c49f9

@ -605,6 +605,26 @@ exports.addDepartment = async (request, reply) => {
} }
}; };
exports.getDetails = async (request, reply) => {
try {
const { id } = request.params;
let data;
if (id.startsWith('AWBR')) {
data = await Branch.findOne({ branchId: id });
} else {
data = await City.findOne({ cityId: id });
}
if (!data) {
return reply.status(404).send({ message: 'Not found' });
}
reply.send({ data });
} catch (err) {
reply.status(500).send({ message: err.message });
}
};
exports.getCityDetails = async (request, reply) => { exports.getCityDetails = async (request, reply) => {
try { try {
const cityId = request.params.cityId; const cityId = request.params.cityId;

@ -175,21 +175,38 @@ module.exports = function (fastify, opts, next) {
}, },
handler: departmentController.editcity, 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({ fastify.route({
method: "GET", method: "GET",
url: "/api/city/:cityId", url: "/api/details/:id",
schema: { schema: {
tags: ["Department"], tags: ["Department"],
description: "This is for fetching a City details", description: "This is for fetching details of a branch or city",
summary: "This is for fetching a City details", summary: "This is for fetching details of a branch or city",
params: { params: {
type: "object", type: "object",
properties: { properties: {
cityId: { type: "string" } id: { type: "string" }
} }
} }
}, },
handler: departmentController.getCityDetails handler: departmentController.getDetails
}); });
fastify.route({ fastify.route({
method: "GET", method: "GET",

Loading…
Cancel
Save