From 4557230e6b64aff25cd9f3cd715185d0967f624e Mon Sep 17 00:00:00 2001 From: Varun Date: Thu, 5 Sep 2024 11:51:07 +0530 Subject: [PATCH] get all quotations --- src/controllers/storeController.js | 18 ++++++++++++++++-- src/routes/storeRoute.js | 16 ++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/controllers/storeController.js b/src/controllers/storeController.js index 0812881d..d2a8ee73 100644 --- a/src/controllers/storeController.js +++ b/src/controllers/storeController.js @@ -1098,7 +1098,7 @@ exports.createquotationforSensor = async (req, reply) => { const savedQuotation = await newQuotation.save(); // Send a success response with the saved document - reply.code(201).send({ + reply.code(200).send({ success: true, message: 'Quotation for sensors created successfully.', data: savedQuotation, @@ -1114,6 +1114,20 @@ exports.createquotationforSensor = async (req, reply) => { } }; - +exports.getallquotationdata = async (req, reply) => { + try { + await SensorQuotation.find({}) + .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); + } +}; diff --git a/src/routes/storeRoute.js b/src/routes/storeRoute.js index 5629bebd..2b2f6ed6 100644 --- a/src/routes/storeRoute.js +++ b/src/routes/storeRoute.js @@ -802,5 +802,21 @@ fastify.post("/api/createquotationforSensor/:installationId", { }) + +fastify.get("/api/getallquotationdata", { + schema: { + tags: ["Install"], + description: "This is for Get All Quotation Data", + summary: "This is for to Get All Quotation Data", + + security: [ + { + basicAuth: [], + }, + ], + }, + // preHandler: fastify.auth([fastify.authenticate]), + handler: storeController.getallquotationdata, +}); next(); };