get all designations particular fileds

master
Bhaskar 10 months ago
parent 065a0fb0ce
commit 640ff2788b

@ -135,6 +135,9 @@ exports.getAllDepartmentsParticularFields = async (req, reply) => {
cities: [...new Set(departments.map((doc) => doc.city))],
zones: [...new Set(departments.map((doc) => doc.zone))],
pincodes: [...new Set(departments.map((doc) => doc.pincode))],
departments: [...new Set(departments.map((doc) => doc.departmentName))],
states: [...new Set(departments.map((doc) => doc.state))],
countries: [...new Set(departments.map((doc) => doc.country))],
};
// Sending the response
@ -393,3 +396,31 @@ exports.getAllDepartmentsParticularFields = async (req, reply) => {
reply.status(500).send({ message: err.message });
}
};
exports.getAllDesignationsParticularFields = async (req, reply) => {
try {
const departments = await Desgination.find().exec();
// Grouping the data
const result = {
cities: [...new Set(departments.map((doc) => doc.city))],
zones: [...new Set(departments.map((doc) => doc.zone))],
pincodes: [...new Set(departments.map((doc) => doc.pincode))],
departments: [...new Set(departments.map((doc) => doc.departmentName))],
states: [...new Set(departments.map((doc) => doc.state))],
countries: [...new Set(departments.map((doc) => doc.country))],
designations: [...new Set(departments.map((doc) => doc.desginationName))],
reportingMangers: [...new Set(departments.map((doc) => doc.reportingManager))],
};
// Sending the response
reply.send({
status_code: 200,
data: result,
count: departments.length,
});
} catch (err) {
console.error(err);
reply.send({ error: err.message });
}
};

@ -287,6 +287,22 @@ module.exports = function (fastify, opts, next) {
},
handler: departmentController.editdesgination,
});
fastify.get("/api/getalldesignationsParticularFileds", {
schema: {
tags: ["Department"],
description: "This is for Get all Designation particular fileds Data",
summary: "This is for to Get all Designation particular fields Data",
security: [
{
basicAuth: [],
},
],
},
//preHandler: fastify.auth([fastify.authenticate]),
handler: departmentController.getAllDesignationsParticularFields,
});
next();
};
Loading…
Cancel
Save