feat: added get area, rows & bays by zone, area, row id apis
This commit is contained in:
@@ -102,4 +102,24 @@ module.exports = {
|
||||
next(error);
|
||||
}
|
||||
},
|
||||
|
||||
getAreaRowsByID: async (req, res, next) => {
|
||||
const { id } = req.params;
|
||||
|
||||
if (!id) {
|
||||
res.status(400).send({ success: false, message: "Missing id param" });
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const areaData = await Area.findById(id).populate("rows");
|
||||
if (!areaData) {
|
||||
res.status(404).send({ success: false, message: "not found" });
|
||||
return;
|
||||
}
|
||||
res.send({ success: true, data: areaData.rows });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -11,6 +11,11 @@ router.get("/all", controller.getAllArea);
|
||||
*/
|
||||
router.get("/:id", controller.getAreaByID);
|
||||
|
||||
/**
|
||||
* @route /area/:id/rows
|
||||
*/
|
||||
router.get("/:id/rows", controller.getAreaRowsByID);
|
||||
|
||||
/**
|
||||
* @route /area/
|
||||
*/
|
||||
|
||||
@@ -102,4 +102,24 @@ module.exports = {
|
||||
next(error);
|
||||
}
|
||||
},
|
||||
|
||||
getRowBaysByID: async (req, res, next) => {
|
||||
const { id } = req.params;
|
||||
|
||||
if (!id) {
|
||||
res.status(400).send({ success: false, message: "Missing id param" });
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const rowData = await Row.findById(id).populate("bays");
|
||||
if (!rowData) {
|
||||
res.status(404).send({ success: false, message: "not found" });
|
||||
return;
|
||||
}
|
||||
res.send({ success: true, data: rowData.bays });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -12,6 +12,11 @@ router.get("/all", controller.getAllRow);
|
||||
*/
|
||||
router.get("/:id", controller.getRowByID);
|
||||
|
||||
/**
|
||||
* @route /row/:id/bays
|
||||
*/
|
||||
router.get("/:id/bays", controller.getRowBaysByID);
|
||||
|
||||
/**
|
||||
* @route /row/
|
||||
*/
|
||||
|
||||
@@ -102,4 +102,24 @@ module.exports = {
|
||||
next(error);
|
||||
}
|
||||
},
|
||||
|
||||
getZoneAreasByID: async (req, res, next) => {
|
||||
const { id } = req.params;
|
||||
|
||||
if (!id) {
|
||||
res.status(400).send({ success: false, message: "Missing id param" });
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const zoneData = await Zone.findById(id).populate("areas");
|
||||
if (!zoneData) {
|
||||
res.status(404).send({ success: false, message: "not found" });
|
||||
return;
|
||||
}
|
||||
res.send({ success: true, data: zoneData.areas });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -12,6 +12,11 @@ router.get("/all", controller.getAllZone);
|
||||
*/
|
||||
router.get("/:id", controller.getZoneByID);
|
||||
|
||||
/**
|
||||
* @route /zone/:id/areas
|
||||
*/
|
||||
router.get("/:id/areas", controller.getZoneAreasByID);
|
||||
|
||||
/**
|
||||
* @route /zone/
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user