From a2e0e0e8d8b4ac342ab57be0abe635dc46c38d59 Mon Sep 17 00:00:00 2001 From: varun Date: Tue, 2 Jul 2024 03:33:26 -0400 Subject: [PATCH] motor action and added installerid in bore creation --- src/controllers/tankersController.js | 8 ++++++-- src/controllers/tanksController.js | 2 +- src/models/tankers.js | 2 +- src/routes/tankersRoute.js | 9 +++++---- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/controllers/tankersController.js b/src/controllers/tankersController.js index 4159a4a8..29d31b05 100644 --- a/src/controllers/tankersController.js +++ b/src/controllers/tankersController.js @@ -388,12 +388,13 @@ exports.addBores = async (req, reply) => { try { - var customerId = req.params.customerId; + var InstallerId = req.params.InstallerId; //console.log(customerId); //const username = loginObject.user.username; boresData = { - customerId:customerId, + InstallerId:InstallerId, + customerId:req.body.customerId, boreName: req.body.boreName, capacity: req.body.capacity, typeofwater: req.body.typeofwater, @@ -414,6 +415,9 @@ exports.addBores = async (req, reply) => { if (checkFormEncoding.isUserFormUrlEncoded) { usertobeInserted = checkFormEncoding.bores; console.log("thsi true url string"); + + bores.InstallerId = usertobeInserted.InstallerId + bores.customerId = usertobeInserted.customerId bores.boreName = usertobeInserted.boreName; bores.capacity = usertobeInserted.capacity; diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index e7820ffd..be07c2de 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -1097,7 +1097,7 @@ exports.motorAction = async (req, reply) => { const newMotorData = new MotorData({ customerId: customerId, - motor_id: motor_id, + motor_id: motorId, start_instance_id: start_instance_id, supplierTank: req.body.from, receiverTank: req.body.to, diff --git a/src/models/tankers.js b/src/models/tankers.js index 7614c549..ba2a14ef 100644 --- a/src/models/tankers.js +++ b/src/models/tankers.js @@ -76,7 +76,7 @@ const tankersbookingSchema = new mongoose.Schema({ const boreSchema = new mongoose.Schema({ customerId: { type: String, default: null }, - + InstallerId: { type: String, default: null }, boreName: { type: String, default: null }, capacity: { type: String, default: null }, typeofwater: { type: String, default: null }, diff --git a/src/routes/tankersRoute.js b/src/routes/tankersRoute.js index 47d7e9cf..6e934177 100644 --- a/src/routes/tankersRoute.js +++ b/src/routes/tankersRoute.js @@ -269,18 +269,18 @@ module.exports = function (fastify, opts, next) { fastify.route({ method: "POST", - url: "/api/addBores/:customerId", + url: "/api/addBores/:InstallerId", schema: { tags: ["Tank"], description: "This is to cretae New Bore", summary: "This is to Create New Bore.", params: { - required: ["customerId"], + required: ["InstallerId"], type: "object", properties: { - customerId: { + InstallerId: { type: "string", - description: "customerId", + description: "InstallerId", }, }, }, @@ -288,6 +288,7 @@ module.exports = function (fastify, opts, next) { type: "object", properties: { boreName: { type: "string" }, + customerId: { type: "string" }, capacity: { type: "string" }, typeofwater: { type: "string" }, description: { type: "string" },