Installing master

master
varun 1 year ago
parent 5caf396cb0
commit 937570b4b6

@ -530,6 +530,32 @@ exports.addStore = async (request, reply) => {
}; };
exports.installwaterlevelSensor = async (request, reply) => {
try {
const { storeId } = request.params;
const updateData = request.body;
// Find the document by hardwareId and update it with the fields received in the body
const updatedSensor = await WaterLeverSensor.findOneAndUpdate(
{ storeId:storeId,hardwareId: request.body.hardwareId, },
{ $set: updateData },
{ new: true } // Return the updated document
);
if (!updatedSensor) {
return reply.status(404).send({ error: 'Sensor not found' });
}
return reply.status(200).send(updatedSensor);
} catch (error) {
console.error(error);
return reply.status(500).send({ error: 'An error occurred while updating the sensor' });
}
};
exports.qccheckwaterlevelSensor = async (request, reply) => { exports.qccheckwaterlevelSensor = async (request, reply) => {
try { try {
const { hardwareId } = request.params; const { hardwareId } = request.params;

@ -154,6 +154,37 @@ fastify.post("/api/createwaterlevelSensor/:storeId", {
handler: storeController.createwaterlevelSensor, handler: storeController.createwaterlevelSensor,
}) })
fastify.post("/api/installwaterlevelSensor/:storeId", {
schema: {
description: "This is for installing waterlevel Sensor",
tags: ["Store-Data"],
summary: "This is for installing waterlevel Sensor",
params: {
required: ["storeId"],
type: "object",
properties: {
storeId: {
type: "string",
description: "storeId",
},
},
},
body: {
type: "object",
properties: {
hardwareId: { type: "string" },
dateofinstallation: { type: "string" },
customerId: { type: "string" },
installedby: { type: "string" }
},
},
},
handler: storeController.installwaterlevelSensor,
})
fastify.post("/api/qccheckwaterlevelSensor/:hardwareId", { fastify.post("/api/qccheckwaterlevelSensor/:hardwareId", {
schema: { schema: {
description: "This is for checking waterlevel Sensor", description: "This is for checking waterlevel Sensor",

Loading…
Cancel
Save