From e3b00c6782819a7fce5f37d6f6037fd72b66155b Mon Sep 17 00:00:00 2001 From: varun Date: Wed, 22 Feb 2023 00:51:48 -0500 Subject: [PATCH] created get booking data of a tanker --- src/controllers/tankersController.js | 23 +++++++++++++++++++++++ src/routes/tankersRoute.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/src/controllers/tankersController.js b/src/controllers/tankersController.js index 22b9b4a1..351e00a4 100644 --- a/src/controllers/tankersController.js +++ b/src/controllers/tankersController.js @@ -174,6 +174,29 @@ exports.getTanker = async (req, reply) => { } }; + + + +exports.getTankersBookingdetails = async (req, reply) => { + try { + const customerId = req.params.customerId + const tankerName = req.query.tankerName + + await Tankerbooking.find({ customerId:customerId,tankerName: tankerName, } + .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.addBores = async (req, reply) => { try { diff --git a/src/routes/tankersRoute.js b/src/routes/tankersRoute.js index ab4b99d7..c5fe670c 100644 --- a/src/routes/tankersRoute.js +++ b/src/routes/tankersRoute.js @@ -272,6 +272,34 @@ module.exports = function (fastify, opts, next) { //onResponse: validationHandler.sendPhoneVerificationCode, }); + fastify.get("/api/getTankersBookingdetails/:customerId", { + schema: { + tags: ["Supplier"], + description: "This is for Get Tanker Booking Data", + summary: "This is for to Get Tanker Booking Data", + params: { + required: ["customerId"], + type: "object", + properties: { + customerId: { + type: "string", + description: "customerId", + }, + }, + }, + querystring: { + tankerName: {type: 'string'} + }, + security: [ + { + basicAuth: [], + }, + ], + }, + preHandler: fastify.auth([fastify.authenticate]), + handler: tankersController.getTankersBookingdetails, + }); + fastify.get("/api/getBores", { schema: { tags: ["Supplier"],