surya 2021-08-21 17:27:10 +05:30
commit f547d18bc3
2 changed files with 37 additions and 7 deletions

View File

@ -1,10 +1,36 @@
//const db = require("../models");
//const Entities = db.tutorials;
const { Op } = require("sequelize");
const { sequelize, Entities , Financials , Statementsmaster , Sectionsmaster , Subsectionsmaster , Brokenperiods } = require('../models') const { sequelize, Entities , Financials , Statementsmaster , Sectionsmaster , Subsectionsmaster , Brokenperiods } = require('../models')
const { logMsg } = require('../services/logger.js'); const { logMsg } = require('../services/logger.js');
// all master data list
exports.MasterDatas = async (req, res) => {
await Statementsmaster.findAll({
where :{is_active : 1} ,
attributes: ['id', 'statement', 'is_active'],
include :[{
association: 'sectionsmasterData' ,
where :{is_active : 1} ,
attributes: ['id', 'section', 'is_active'],
include :[{
association: 'subsectionsmasterData' ,
where :{is_active : 1} ,
attributes: ['id', 'subsection', 'is_active'],
required :false
}],
required :false
}],
required :false
})
.then(data =>
{
res.send({'status':200,'message':"success",'data':data});
logMsg.info("Master Data List api call Success");
})
.catch(err => {
res.status(404).send({'status':404,
message: err.message || "Some error occurred while retrieving statements." ,'data': "No data" });
});
};
// menu list api // menu list api
exports.MenuList = async (req, res) => { exports.MenuList = async (req, res) => {
@ -37,7 +63,8 @@ exports.MenuList = async (req, res) => {
obj_data = { ...value.dataValues , statementsmasterrData:MasterData} obj_data = { ...value.dataValues , statementsmasterrData:MasterData}
data.push(obj_data); data.push(obj_data);
}); });
return res.send({'status':200,'message':"success",'data':data}); res.send({'status':200,'message':"success",'data':data});
logMsg.info("MenuList api working");
} catch (err) { } catch (err) {
console.log(err) console.log(err)
return res.status(500).json({'status':404,'message':"failed",'data':"No data"}) return res.status(500).json({'status':404,'message':"failed",'data':"No data"})

View File

@ -26,6 +26,9 @@ module.exports = app => {
// Retrieve all Broken periods // Retrieve all Broken periods
router.get("/BrokenPeriodsList/:entityid", financials.BrokenPeriodsList); router.get("/BrokenPeriodsList/:entityid", financials.BrokenPeriodsList);
// fetchind all master data
router.get("/MasterDatas", financials.MasterDatas);
//master.controller api's //master.controller api's
// get statment master data // get statment master data
@ -215,7 +218,7 @@ module.exports = app => {
// third party api call example // third party api call example
router.get('/third_party_api', (req, res) => { router.get('/third_party_api', (req, res) => {
const options = { const options = {
url: "http://localhost:3000/api/EntitiesList", url: "http://localhost:4000/api/MenuList/MW112233",
}; };
request.get(options).pipe(res); request.get(options).pipe(res);
}) })