diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index 74d83ab6..aca0d437 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -67,8 +67,8 @@ console.log(req.params); exports.updateTanksInfo = async (req, reply) => { try { - const customerId = req.params.customerId; - const tankName = req.params.tankName; + var customerId = req.params.customerId; + var tankName = req.query.tankName; const tank = req.body; const { ...updateData } = tank; const update = await Tank.findOneAndUpdate({ tankName: tankName,customerId:customerId, }, updateData, { new: true }); @@ -87,9 +87,9 @@ exports.updateTanksInfo = async (req, reply) => { //delete selected tank exports.deleteTanksInfo = async (req, reply) => { try { - const username = loginObject.user.username; - const tankName = req.params.tankName; - const tank = await Tank.findOneAndDelete({ tankName: tankName,userName:username }); + var customerId = req.params.customerId; + var tankName = req.query.tankName; + const tank = await Tank.findOneAndDelete({ tankName: tankName,customerId:customerId }); reply.send({ status_code: 200, data: tank}); // return tank; @@ -101,7 +101,7 @@ exports.deleteTanksInfo = async (req, reply) => { //get tanks data by passing username exports.getTank = async (req, reply) => { try { - await Tank.find({userName: req.query.userName}) + await Tank.find({customerId: req.query.customerId}) .exec() .then((docs) => { reply.send({ status_code: 200, data: docs, count: docs.length }); diff --git a/src/routes/tanksRoute.js b/src/routes/tanksRoute.js index dfc1bcc6..2a4db66b 100644 --- a/src/routes/tanksRoute.js +++ b/src/routes/tanksRoute.js @@ -48,7 +48,7 @@ module.exports = function (fastify, opts, next) { fastify.route({ method: "PUT", - url: "/api/updateTanks/:customerId/:tankName", + url: "/api/updateTanks/:customerId", schema: { tags: ["Tank"], summary: "This is for update tank", @@ -96,20 +96,23 @@ module.exports = function (fastify, opts, next) { fastify.route({ method: "PUT", - url: "/api/deleteTank/:tankName", + url: "/api/deleteTank/:customerId", schema: { tags: ["Tank"], summary: "This is for delete tank", params: { - required: ["tankName"], + required: ["customerId"], type: "object", properties: { - tankName: { + customerId: { type: "string", - description: "tankName", + description: "customerId", }, }, }, + querystring: { + tankName: {type: 'string'} + }, security: [ { basicAuth: [], @@ -127,7 +130,7 @@ module.exports = function (fastify, opts, next) { description: "This is for Get Tank Data", summary: "This is for to Get Tank Data", querystring: { - userName: {type: 'string'} + customerId: {type: 'string'} }, security: [ {