From 5ab22f5d2bb8764512e4877f927d33189005204d Mon Sep 17 00:00:00 2001 From: surya Date: Mon, 23 Aug 2021 17:28:01 +0530 Subject: [PATCH] Surya: Filter Api --- app/controllers/master.controller.js | 15 +++++++++++++++ app/routes/routes.js | 10 ++++++++++ 2 files changed, 25 insertions(+) diff --git a/app/controllers/master.controller.js b/app/controllers/master.controller.js index 2cc7862..a51e4e9 100644 --- a/app/controllers/master.controller.js +++ b/app/controllers/master.controller.js @@ -322,6 +322,21 @@ exports.Deleteitem = (req, res) => { }); }; +//ItemFilter +// Retrieve all items from the database which is under by the represent section. +exports.ItemFilter = (req, res) => { + const section = req.params.section + Itemsmaster.findAll({where : { section : section }}) + // sequelize.query("SELECT itemsmaster.id,itemsmaster.statement as statement_id,statementsmaster.statement,itemsmaster.section as section_id,sectionsmaster.section,itemsmaster.subsection as subsection_id,subsectionsmaster.subsection,subsectionsmaster.itemtext as subsection_itemtext ,itemsmaster.itemtext,itemsmaster.is_active,pvtltd,llp,others,formula,is_calculated,itemsmaster.createdby,itemsmaster.createdon,itemsmaster.updatedby,itemsmaster.updatedon FROM itemsmaster JOIN statementsmaster ON itemsmaster.statement=statementsmaster.id JOIN sectionsmaster ON itemsmaster.section= sectionsmaster.id JOIN subsectionsmaster ON itemsmaster.subsection= subsectionsmaster.id") + .then(data => { + res.send({'status':200,'message':"success",'data':data}); + logMsg.info("Success :"(data)); + }) + .catch(err => { + res.send({'status':404, + message: err.message || "Some error occurred while retrieving items." ,'data': "No data" }); + }); +}; diff --git a/app/routes/routes.js b/app/routes/routes.js index 295d2aa..22e0855 100644 --- a/app/routes/routes.js +++ b/app/routes/routes.js @@ -211,6 +211,16 @@ module.exports = app => { //router.delete("/:id", tutorials.delete); +/** + * @openapi + * /api/ItemList: + * get: + * description: Welcome to swagger-jsdoc! + * responses: + * 200: + * description: Returns a mysterious string. + */ + router.get("/ItemFilter/:section", master.ItemFilter);