master^2
Bhaskar 1 month ago
parent acb96d87e6
commit 0f537efc1f

@ -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) => {
try {
const cityId = request.params.cityId;

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

Loading…
Cancel
Save