From 94af513b6ee823d3fccb2c0e1bae238cd7f0752b Mon Sep 17 00:00:00 2001 From: Bhaskara Kishore Date: Fri, 24 Mar 2023 17:51:50 +0530 Subject: [PATCH] latitude and longitude --- src/controllers/supplierController.js | 8 +++++++- src/handlers/supplierHandler.js | 4 ++++ src/models/supplier.js | 25 +++++++++++++++---------- src/routes/supplierRoute.js | 2 ++ 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/controllers/supplierController.js b/src/controllers/supplierController.js index 7cf9437e..017328d3 100644 --- a/src/controllers/supplierController.js +++ b/src/controllers/supplierController.js @@ -80,6 +80,8 @@ exports.loginSupplier = async (req) => { office_adress: req.body.office_adress, zip: req.body.zip, }, + latitude: req.body.latitude, + longitude: req.body.longitude }; var supplier = new Supplier(s_data); @@ -102,6 +104,8 @@ exports.loginSupplier = async (req) => { supplier.supplierId = suppliertobeInserted.supplier_id; supplier.office_adress = suppliertobeInserted.office_adress; supplier.alternativeContactNumber = suppliertobeInserted.alternativeContactNumber; + supplier.latitude = suppliertobeInserted.latitude; + supplier.longitude = suppliertobeInserted.longitude; } @@ -120,7 +124,7 @@ exports.loginSupplier = async (req) => { role = ["supplier"]; supplier.profile.role = role; } - + insertedSupplier = await supplier.save(); console.log(insertedSupplier); if (insertedSupplier) { @@ -137,6 +141,8 @@ exports.loginSupplier = async (req) => { }, ], profile: insertedSupplier.profile, + latitude: insertedSupplier.latitude, + longitude: insertedSupplier.longitude }, status_code: 200, }; diff --git a/src/handlers/supplierHandler.js b/src/handlers/supplierHandler.js index 7b36943a..569d1f0e 100644 --- a/src/handlers/supplierHandler.js +++ b/src/handlers/supplierHandler.js @@ -192,6 +192,8 @@ exports.loginSupplier = async(request, reply) =>{ office_address: loginObject.supplier.profile.office_address, phoneVerified: loginObject.supplier.phoneVerified, oneTimePasswordSetFlag: loginObject.supplier.oneTimePasswordSetFlag, + latitude: loginObject.supplier.latitude, + longitude: loginObject.supplier.longitude, type: loginObject.supplier.profile.role, typeasobj: stringToJsonObject, }, @@ -210,6 +212,8 @@ exports.loginSupplier = async(request, reply) =>{ office_address: loginObject.supplier.profile.office_address, phoneVerified: loginObject.supplier.phoneVerified, oneTimePasswordSetFlag: loginObject.supplier.oneTimePasswordSetFlag, + latitude: loginObject.supplier.latitude, + longitude: loginObject.supplier.longitude, type: loginObject.supplier.profile.role, typeasobj: stringToJsonObject, }, diff --git a/src/models/supplier.js b/src/models/supplier.js index 45bb9eaf..33adfa27 100644 --- a/src/models/supplier.js +++ b/src/models/supplier.js @@ -48,17 +48,22 @@ const supplierSchema = new mongoose.Schema( default: 'pending' }, - currentGPS: { - // It's important to define type within type field, because - // mongoose use "type" to identify field's object type. - - gpsType: { type: String, default: "Point" }, - // Default value is needed. Mongoose pass an empty array to - // array type by default, but it will fail MongoDB's pre-save - // validation. - coordinates: { type: [Number], default: [0, 0] }, - }, + // currentGPS: { + // // It's important to define type within type field, because + // // mongoose use "type" to identify field's object type. + // gpsType: { type: String, default: "Point" }, + // // Default value is needed. Mongoose pass an empty array to + // // array type by default, but it will fail MongoDB's pre-save + // // validation. + // coordinates: { type: [Number], default: [0, 0] }, + // }, + // location: { + // type: { type: String }, + // coordinates: [Number] + // }, + longitude: { type : Number}, + latitude: {type: Number}, isActive: Boolean, tenantId: ObjectId, createdAt: { diff --git a/src/routes/supplierRoute.js b/src/routes/supplierRoute.js index 9e363a8c..9f4f92ed 100644 --- a/src/routes/supplierRoute.js +++ b/src/routes/supplierRoute.js @@ -93,6 +93,8 @@ module.exports = function (fastify, opts, next) { state: { type: "string", default: null }, zip: { type: "string", default: null }, country: { type: "string", default: null }, + latitude: { type: 'number' }, + longitude: { type: 'number'} }, }, security: [