Merge pull request #22 from kfnawaz/feat/get-child-warehouse-apis

Feat: Get children by warehouse sub modules apis
This commit is contained in:
bluestreamlds
2022-02-09 22:07:30 +05:30
committed by GitHub
14 changed files with 175 additions and 0 deletions

View File

@@ -102,4 +102,24 @@ module.exports = {
next(error); 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);
}
},
}; };

View File

@@ -11,6 +11,11 @@ router.get("/all", controller.getAllArea);
*/ */
router.get("/:id", controller.getAreaByID); router.get("/:id", controller.getAreaByID);
/**
* @route /area/:id/rows
*/
router.get("/:id/rows", controller.getAreaRowsByID);
/** /**
* @route /area/ * @route /area/
*/ */

View File

@@ -104,4 +104,24 @@ module.exports = {
next(error); next(error);
} }
}, },
getBayLevelsByID: async (req, res, next) => {
const { id } = req.params;
if (!id) {
res.status(400).send({ success: false, message: "Missing id param" });
return;
}
try {
const bayData = await Bay.findById(id).populate("levels");
if (!bayData) {
res.status(404).send({ success: false, message: "not found" });
return;
}
res.send({ success: true, data: bayData.levels });
} catch (error) {
next(error);
}
},
}; };

View File

@@ -12,6 +12,11 @@ router.get("/all", controller.getAllBay);
*/ */
router.get("/:id", controller.getBayByID); router.get("/:id", controller.getBayByID);
/**
* @route /bay/:id/levels
*/
router.get("/:id/levels", controller.getBayLevelsByID);
/** /**
* @route /bay/ * @route /bay/
*/ */

View File

@@ -102,4 +102,24 @@ module.exports = {
next(error); next(error);
} }
}, },
getLevelSublevelsByID: async (req, res, next) => {
const { id } = req.params;
if (!id) {
res.status(400).send({ success: false, message: "Missing id param" });
return;
}
try {
const levelData = await Level.findById(id).populate({ path: "sub_levels", populate: { path: "sub_level_id" } });
if (!levelData) {
res.status(404).send({ success: false, message: "not found" });
return;
}
res.send({ success: true, data: levelData.sub_levels });
} catch (error) {
next(error);
}
},
}; };

View File

@@ -12,6 +12,11 @@ router.get("/all", controller.getAllLevel);
*/ */
router.get("/:id", controller.getLevelByID); router.get("/:id", controller.getLevelByID);
/**
* @route /level/:id/sublevels
*/
router.get("/:id/sublevels", controller.getLevelSublevelsByID);
/** /**
* @route /level/ * @route /level/
*/ */

View File

@@ -102,4 +102,24 @@ module.exports = {
next(error); 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);
}
},
}; };

View File

@@ -12,6 +12,11 @@ router.get("/all", controller.getAllRow);
*/ */
router.get("/:id", controller.getRowByID); router.get("/:id", controller.getRowByID);
/**
* @route /row/:id/bays
*/
router.get("/:id/bays", controller.getRowBaysByID);
/** /**
* @route /row/ * @route /row/
*/ */

View File

@@ -162,4 +162,24 @@ module.exports = {
next(error); next(error);
} }
}, },
getSubLevelChildrenByID: async (req, res, next) => {
const { id } = req.params;
if (!id) {
res.status(400).send({ success: false, message: "Missing id param" });
return;
}
try {
const sublevelData = await Sublevel.findById(id).populate({ path: "sub_levels", populate: { path: "sub_level_id" } });
if (!sublevelData) {
res.status(404).send({ success: false, message: "not found" });
return;
}
res.send({ success: true, data: sublevelData.sub_levels });
} catch (error) {
next(error);
}
},
}; };

View File

@@ -12,6 +12,11 @@ router.get("/all", controller.getAllSublevel);
*/ */
router.get("/:id", controller.getSubLevelByID); router.get("/:id", controller.getSubLevelByID);
/**
* @route /sublevel/:id/sublevels
*/
router.get("/:id/sublevels", controller.getSubLevelChildrenByID);
/** /**
* @route /sublevel/ * @route /sublevel/
*/ */

View File

@@ -124,4 +124,24 @@ module.exports = {
next(error); next(error);
} }
}, },
getWarehouseZonesByID: async (req, res, next) => {
const { id } = req.params;
if (!id) {
res.status(400).send({ success: false, message: "Missing id param" });
return;
}
try {
const warehouseData = await Warehouse.findById(id).populate("zones");
if (!warehouseData) {
res.status(404).send({ success: false, message: "not found" });
return;
}
res.send({ success: true, data: warehouseData.zones });
} catch (error) {
next(error);
}
},
}; };

View File

@@ -12,6 +12,11 @@ router.get("/all", controller.getAllWarehouse);
*/ */
router.get("/:id", controller.getWarehouseByID); router.get("/:id", controller.getWarehouseByID);
/**
* @route /warehouse/:id/zones
*/
router.get("/:id/zones", controller.getWarehouseZonesByID);
/** /**
* @route /warehouse/ * @route /warehouse/
*/ */

View File

@@ -102,4 +102,24 @@ module.exports = {
next(error); 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);
}
},
}; };

View File

@@ -12,6 +12,11 @@ router.get("/all", controller.getAllZone);
*/ */
router.get("/:id", controller.getZoneByID); router.get("/:id", controller.getZoneByID);
/**
* @route /zone/:id/areas
*/
router.get("/:id/areas", controller.getZoneAreasByID);
/** /**
* @route /zone/ * @route /zone/
*/ */