From 58fe8288fbfafc85973b4d3718def076990ff1d2 Mon Sep 17 00:00:00 2001 From: sriramv Date: Sat, 14 Aug 2021 10:38:02 +0530 Subject: [PATCH] menu_list:GWM --- app/controllers/financial.controller.js | 27 ++++++++++++++++++++----- app/models/Sectionsmaster.js | 3 ++- app/models/Statementsmaster.js | 3 ++- app/models/Subsectionsmaster.js | 1 + 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/app/controllers/financial.controller.js b/app/controllers/financial.controller.js index b3794fb..6d0d10c 100644 --- a/app/controllers/financial.controller.js +++ b/app/controllers/financial.controller.js @@ -8,19 +8,36 @@ const { logMsg } = require('../services/logger.js'); // menu list api exports.MenuList = async (req, res) => { - + //findAll({ where :{is_active : 1} ,include : { association: 'sectionsmasterData' } }); + //findAll({ where :{is_active : 1} , include: { all: true, nested: true , where :{is_active : 1} }}); try { const losid = req.params.losid - //const MasterData = await Statementsmaster.findAll({include : 'sectionsmasterData'}); - let EntitiesData = await Entities.findAll({where : { losid } }); - - return res.send({'status':200,'message':"success",'data':EntitiesData}); + const MasterData = await Statementsmaster.findAll({ + where :{is_active : 1} , + include :[{ + association: 'sectionsmasterData' , + where :{is_active : 1} , + include :[{ + association: 'subsectionsmasterData' , + //where :{is_active : 1} + }] + }] + }); + const EntitiesData = await Entities.findAll({where : { losid } }); + let data = []; + EntitiesData.forEach((value, key)=>{ + obj_data = { ...value.dataValues , statementsmasterrData:MasterData} + data.push(obj_data); + }); + return res.send({'status':200,'message':"success",'data':data}); } catch (err) { console.log(err) return res.status(500).json({'status':404,'message':"failed",'data':"No data"}) } }; + + // Retrieve all Entities from the database. exports.findAllEntities = (req, res) => { diff --git a/app/models/Sectionsmaster.js b/app/models/Sectionsmaster.js index 50a1014..9a40dce 100644 --- a/app/models/Sectionsmaster.js +++ b/app/models/Sectionsmaster.js @@ -20,7 +20,8 @@ module.exports = (sequelize, DataTypes) => { Sectionsmaster.init( { statement: { type: DataTypes.INTEGER }, - section: { type: DataTypes.STRING }, + section: { type: DataTypes.STRING }, + is_active: { type: DataTypes.INTEGER }, createdby: { type: DataTypes.INTEGER }, updatedby: { type: DataTypes.INTEGER }, diff --git a/app/models/Statementsmaster.js b/app/models/Statementsmaster.js index 3402f12..09065bf 100644 --- a/app/models/Statementsmaster.js +++ b/app/models/Statementsmaster.js @@ -17,7 +17,8 @@ module.exports = (sequelize, DataTypes) => { } Statementsmaster.init( { - statement: { type: DataTypes.STRING }, + statement: { type: DataTypes.STRING }, + is_active: { type: DataTypes.INTEGER }, createdby: { type: DataTypes.INTEGER }, updatedby: { type: DataTypes.INTEGER }, diff --git a/app/models/Subsectionsmaster.js b/app/models/Subsectionsmaster.js index 9486307..fe6583d 100644 --- a/app/models/Subsectionsmaster.js +++ b/app/models/Subsectionsmaster.js @@ -22,6 +22,7 @@ module.exports = (sequelize, DataTypes) => { section: { type: DataTypes.INTEGER }, subsection: { type: DataTypes.STRING }, itemtext: { type: DataTypes.STRING }, + is_active: { type: DataTypes.INTEGER }, createdby: { type: DataTypes.INTEGER }, updatedby: { type: DataTypes.INTEGER },