apis to get all delivery boys and active delivery boys under supplier

master
varun 3 years ago
parent c11917f8ce
commit 88babe0d4c

@ -144,3 +144,40 @@ exports.getbookingsofdeliveryboy = async (req, reply) => {
} }
}; };
exports.getalldeliveryboysofsupplier = async (req, reply) => {
try {
console.log(req.params.supplierId)
await DeliveryBoy.find({supplierId: req.params.supplierId})
.exec()
.then((docs) => {
reply.send({ status_code: 200, data: docs, count: docs.length });
})
.catch((err) => {
console.log(err);
reply.send({ error: err });
});
} catch (err) {
throw boom.boomify(err);
}
};
exports.getactivedeliveryboysofsupplier = async (req, reply) => {
try {
console.log(req.params.supplierId)
await DeliveryBoy.find({supplierId: req.params.supplierId,status:"active"})
.exec()
.then((docs) => {
reply.send({ status_code: 200, data: docs, count: docs.length });
})
.catch((err) => {
console.log(err);
reply.send({ error: err });
});
} catch (err) {
throw boom.boomify(err);
}
};

@ -156,7 +156,57 @@ module.exports = function (fastify, opts, next) {
handler: supplierOrderController.getbookingsofdeliveryboy, handler: supplierOrderController.getbookingsofdeliveryboy,
}); });
fastify.get("/api/getalldeliveryboys/:supplierId", {
schema: {
tags: ["Supplier"],
description: "This is for Get all delivery boys under supplier",
summary: "This is for to Get all delivery boys under supplier",
params: {
required: ["supplierId"],
type: "object",
properties: {
supplierId: {
type: "string",
description: "supplierId",
},
},
},
security: [
{
basicAuth: [],
},
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: supplierOrderController.getalldeliveryboysofsupplier,
});
fastify.get("/api/getactivedeliveryboys/:supplierId", {
schema: {
tags: ["Supplier"],
description: "This is for Get all active delivery boys under supplier",
summary: "This is for to Get all active delivery boys under supplier",
params: {
required: ["supplierId"],
type: "object",
properties: {
supplierId: {
type: "string",
description: "supplierId",
},
},
},
security: [
{
basicAuth: [],
},
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: supplierOrderController.getactivedeliveryboysofsupplier,
});
next(); next();
} }

Loading…
Cancel
Save