diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index 83dcebc7..54e65a2d 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -159,6 +159,23 @@ exports.getTank = async (req, reply) => { // } //}; +exports.getTankmotordata = async (req, reply) => { + try { + await MotorData.find({customerId: req.query.customerId}) + .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.updateTanklevels = async (req, reply) => { try { const customerId = req.params.customerId; diff --git a/src/routes/tanksRoute.js b/src/routes/tanksRoute.js index 194e0b91..c8645c4d 100644 --- a/src/routes/tanksRoute.js +++ b/src/routes/tanksRoute.js @@ -543,6 +543,25 @@ module.exports = function (fastify, opts, next) { preHandler: fastify.auth([fastify.authenticate]), handler: tanksController.deletemotordatarecordsbefore7days, }); + + fastify.get("/api/getTankmotordata", { + schema: { + tags: ["Tank"], + description: "This is for Get Tank Motor Data", + summary: "This is for to Get Tank Motor Data", + querystring: { + customerId: {type: 'string'} + }, + security: [ + { + basicAuth: [], + }, + ], + }, + preHandler: fastify.auth([fastify.authenticate]), + handler: tanksController.getTankmotordata, + }); + next(); }