get details of particular hardwareId

master^2
Varun 7 months ago
parent a996574402
commit c0bba501b5

@ -1228,7 +1228,27 @@ exports.generateHardwareMasterId = async (req, reply) => {
}
};
exports.getSensorByHardwareId = async (req, reply) => {
try {
const { storeId } = req.params;
const { hardwareId } = req.body;
if (!hardwareId) {
return reply.code(400).send({ message: 'hardwareId is required' });
}
const sensor = await Insensors.findOne({ storeId, hardwareId });
if (!sensor) {
return reply.code(404).send({ message: 'Sensor not found' });
}
return reply.code(200).send(sensor);
} catch (error) {
console.error('Error fetching sensor by hardwareId:', error);
return reply.code(500).send({ message: 'Internal Server Error' });
}
};
exports.updateSensorById = async (req, reply) => {
try {

@ -1158,6 +1158,29 @@ fastify.post('/api/generateHardwareMasterId/:storeId', {
handler: storeController.generateHardwareMasterId,
});
fastify.post('/api/getSensorByHardwareId/:storeId', {
schema: {
description: 'Fetch details of a specific sensor using hardwareId',
tags: ['Store-Data'],
summary: 'Retrieve sensor details by hardwareId',
params: {
required: ['storeId'],
type: 'object',
properties: {
storeId: { type: 'string', description: 'Store ID' },
},
},
body: {
type: 'object',
required: ['hardwareId'],
properties: {
hardwareId: { type: 'string', description: 'Hardware ID of the sensor' },
},
},
},
handler: storeController.getSensorByHardwareId,
});
fastify.post("/api/updateSensorById/:_id", {
schema: {
description: "Edit specific sensor fields",

Loading…
Cancel
Save