fetching active delivery boys for a particular supplier

master
varun 3 years ago
parent 5c28bf1784
commit ab270bcc91

@ -109,4 +109,21 @@ exports.orderNow = async (req, reply) => {
} catch (err) {
throw boom.boomify(err);
}
};
};
exports.getactiveDeliveryboys = async (req, reply) => {
try {
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);
}
};

@ -101,6 +101,7 @@ const supplierSchema = new mongoose.Schema(
});
const deliveryBoySchema = new mongoose.Schema({
supplierId:{ type: String, default: null },
name: { type: String, default: null },
phone: { type: String, default: null,unique:true },
alternativeContactNumber : { type : String,default: null },
@ -109,7 +110,7 @@ const supplierSchema = new mongoose.Schema(
state: { type: String, default: null },
zip: { type: String, default: null },
timestamp: { type: Date, default: Date.now },
status: { type: String, default: "active" },
status: { type: String, default: "Inactive" },
});

@ -103,6 +103,30 @@ module.exports = function (fastify, opts, next) {
handler: supplierOrderController.addDeliveryboy,
});
fastify.get("/api/getActiveDeliveryboys/:supplierId", {
schema: {
tags: ["Supplier"],
description: "This is for Get avtive delivery boys Data",
summary: "This is for to Get avtive delivery boys Data",
params: {
required: ["supplierId"],
type: "object",
properties: {
supplierId: {
type: "string",
description: "supplierId",
},
},
},
security: [
{
basicAuth: [],
},
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: supplierOrderController.getactiveDeliveryboys,
});
next();

Loading…
Cancel
Save