create a api status connected to display list

master
Bhaskara Kishore 3 years ago
parent c66f1fcba6
commit bdde35206a

@ -28,14 +28,15 @@ console.log(req.params);
tankersData = { tankersData = {
supplierId:supplierId, supplierId:supplierId,
supplier_name:req.body.username, supplier_name:req.body.supplier_name,
supplier_address : req.body.supplier_address, supplier_address : req.body.supplier_address,
tankerName: req.body.tankerName, tankerName: req.body.tankerName,
phoneNumber: req.body.phoneNumber, phoneNumber: req.body.phoneNumber,
alternative_phoneNumber: req.body.alternative_phoneNumber, alternative_phoneNumber: req.body.alternative_phoneNumber,
typeofwater: req.body.typeofwater, typeofwater: req.body.typeofwater,
capacity: req.body.capacity, capacity: req.body.capacity,
price: req.body.price price: req.body.price,
status: req.body.status
}; };
console.log(req.body.typeofwater,req.body.capacity) console.log(req.body.typeofwater,req.body.capacity)
@ -61,6 +62,7 @@ console.log(req.params);
tankers.typeofwater = usertobeInserted.typeofwater; tankers.typeofwater = usertobeInserted.typeofwater;
tankers.supplierId = usertobeInserted.supplierId; tankers.supplierId = usertobeInserted.supplierId;
tankers.price = usertobeInserted.price; tankers.price = usertobeInserted.price;
tankers.status = usertobeInserted.status;
} }
} }
const insertedTanker = await tankers.save(); const insertedTanker = await tankers.save();
@ -437,3 +439,26 @@ exports.updatePipelineInfo = async (req, reply) => {
} }
}; };
exports.status = async (req, reply) => {
try {
var status = req.query.status;
if (status === 'connected') {
try {
const tankers = await Tanker.find({});
console.log("tankers...", tankers)
reply.send(tankers);
} catch (err) {
reply.send({ message: err });
}
} else {
reply.send({ message: 'Not Connected' });
}
}
catch (err) {
throw boom.boomify(err);
}
};

@ -26,6 +26,7 @@ const tankersSchema = new mongoose.Schema({
type: [String], type: [String],
default: [] default: []
}, },
status: { type: String}
}); });

@ -33,7 +33,8 @@ module.exports = function (fastify, opts, next) {
alternative_phoneNumber: { type: "string"}, alternative_phoneNumber: { type: "string"},
typeofwater: { type: "string"}, typeofwater: { type: "string"},
capacity: { type: "string"}, capacity: { type: "string"},
price: {type : "string"} price: {type : "string"},
status: {type: "string"}
}, },
}, },
@ -523,16 +524,30 @@ module.exports = function (fastify, opts, next) {
}, },
], ],
}, },
// preHandler: [
// fastify.auth([fastify.operatorAuthenticate]),
// validationHandler.validatePhoneFormat,
// ],
preHandler: fastify.auth([fastify.authenticate]), preHandler: fastify.auth([fastify.authenticate]),
handler: tankersController.updatePipelineInfo, handler: tankersController.updatePipelineInfo,
}); });
fastify.get("/api/getTanks/status", {
schema: {
tags: ["Supplier"],
description: "This is for Get Tank Data for status connected",
summary: "This is for to Get Tank Data for status connected ",
querystring: {
status: {type: 'string'}
},
security: [
{
basicAuth: [],
},
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: tankersController.status,
});
next(); next();
} }

Loading…
Cancel
Save