gwm
This commit is contained in:
parent
0da977d05d
commit
896222af0c
@ -1,10 +1,26 @@
|
|||||||
//const db = require("../models");
|
//const db = require("../models");
|
||||||
//const Entities = db.tutorials;
|
//const Entities = db.tutorials;
|
||||||
//const Op = db.Sequelize.Op;
|
//const Op = db.Sequelize.Op;
|
||||||
const { sequelize, Entities , Financials} = require('../models')
|
|
||||||
|
const { sequelize, Entities , Financials , Statementsmaster ,Sectionsmaster , Subsectionsmaster } = require('../models')
|
||||||
const { logMsg } = require('../services/logger.js');
|
const { logMsg } = require('../services/logger.js');
|
||||||
|
|
||||||
|
|
||||||
|
// menu list api
|
||||||
|
exports.MenuList = async (req, res) => {
|
||||||
|
|
||||||
|
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});
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err)
|
||||||
|
return res.status(500).json({'status':404,'message':"failed",'data':"No data"})
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
// Retrieve all Entities from the database.
|
// Retrieve all Entities from the database.
|
||||||
exports.findAllEntities = (req, res) => {
|
exports.findAllEntities = (req, res) => {
|
||||||
|
|
||||||
@ -22,5 +38,33 @@ exports.findAllEntities = (req, res) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Retrieve all Entities from the database.
|
||||||
|
exports.StatmentList = (req, res) => {
|
||||||
|
|
||||||
|
Statementsmaster.findAll({include: 'sectionsmasterData' })
|
||||||
|
.then(data => {
|
||||||
|
res.send({'status':200,'message':"success",'data':data});
|
||||||
|
logMsg.info("Success :"(data));
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
res.status(500).send({'status':404,
|
||||||
|
message: err.message || "Some error occurred while retrieving tutorials." ,'data': "No data" });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.test = (req, res) => {
|
||||||
|
sequelize.query("select * from statementsmaster")
|
||||||
|
.then(data => {
|
||||||
|
res.send({'status':200,'message':"success",'data':data});
|
||||||
|
logMsg.info("Success :"(data));
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
res.status(500).send({
|
||||||
|
message:
|
||||||
|
err.message || "Some error occurred while retrieving tutorials."
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -8,9 +8,9 @@ module.exports = (sequelize, DataTypes) => {
|
|||||||
* The `models/index` file will call this method automatically.
|
* The `models/index` file will call this method automatically.
|
||||||
*/
|
*/
|
||||||
// define association here
|
// define association here
|
||||||
//static associate({ Model_name }) {
|
static associate({ Financials }) {
|
||||||
//this.hasMany(Model_name, { foreignKey: 'child_table_prim_key', as: 'child_tbl_name' })
|
this.hasMany(Financials, { foreignKey: 'entity_id', as: 'financials' })
|
||||||
//}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,9 +8,12 @@ module.exports = (sequelize, DataTypes) => {
|
|||||||
* The `models/index` file will call this method automatically.
|
* The `models/index` file will call this method automatically.
|
||||||
*/
|
*/
|
||||||
// define association here
|
// define association here
|
||||||
//static associate({ Model_name }) {
|
static associate({ Statementsmaster }) {
|
||||||
//this.hasMany(Model_name, { foreignKey: 'child_table_prim_key', as: 'child_tbl_name' })
|
this.belongsTo(Statementsmaster, { foreignKey: 'id', as: 'statementsmasterData' })
|
||||||
//}
|
}
|
||||||
|
static associate({ Subsectionsmaster }) {
|
||||||
|
this.hasMany(Subsectionsmaster, { foreignKey: 'section', as: 'subsectionsmasterData' })
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,10 +8,11 @@ module.exports = (sequelize, DataTypes) => {
|
|||||||
* The `models/index` file will call this method automatically.
|
* The `models/index` file will call this method automatically.
|
||||||
*/
|
*/
|
||||||
// define association here
|
// define association here
|
||||||
//static associate({ Model_name }) {
|
static associate({ Sectionsmaster }) {
|
||||||
//this.hasMany(Model_name, { foreignKey: 'child_table_prim_key', as: 'child_tbl_name' })
|
this.hasMany(Sectionsmaster, { foreignKey: 'statement', as: 'sectionsmasterData' })
|
||||||
//}
|
}
|
||||||
|
|
||||||
|
//Sectionsmaster.hasMany(Subsectionsmaster, { foreignKey: 'section', as: 'subsectionsmaster' })
|
||||||
|
|
||||||
}
|
}
|
||||||
Statementsmaster.init(
|
Statementsmaster.init(
|
||||||
|
|||||||
@ -8,9 +8,12 @@ module.exports = (sequelize, DataTypes) => {
|
|||||||
* The `models/index` file will call this method automatically.
|
* The `models/index` file will call this method automatically.
|
||||||
*/
|
*/
|
||||||
// define association here
|
// define association here
|
||||||
//static associate({ Model_name }) {
|
static associate({ Sectionsmaster }) {
|
||||||
//this.hasMany(Model_name, { foreignKey: 'child_table_prim_key', as: 'child_tbl_name' })
|
this.belongsTo(Sectionsmaster, { foreignKey: 'id', as: 'sectionsmasterData' })
|
||||||
//}
|
}
|
||||||
|
// static associate({ Model_name }) {
|
||||||
|
// this.hasMany(Model_name, { foreignKey: 'child_table_prim_key', as: 'child_tbl_name' })
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,10 +6,20 @@ module.exports = app => {
|
|||||||
|
|
||||||
// Retrieve all Tutorials
|
// Retrieve all Tutorials
|
||||||
router.get("/EntitiesList", financials.findAllEntities);
|
router.get("/EntitiesList", financials.findAllEntities);
|
||||||
|
// get statment master data
|
||||||
|
router.get("/StatmentList", financials.StatmentList);
|
||||||
|
// get statment master data
|
||||||
|
router.get("/MenuList/:losid", financials.MenuList);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// query execution test
|
||||||
|
router.get("/test", financials.test);
|
||||||
|
|
||||||
// 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 = {
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
require('dotenv').config();
|
||||||
const express = require('express')
|
const express = require('express')
|
||||||
const app = express()
|
const app = express()
|
||||||
app.use(express.json())
|
app.use(express.json())
|
||||||
@ -5,9 +6,11 @@ app.use(express.json())
|
|||||||
app.get("/", (req, res) => {
|
app.get("/", (req, res) => {
|
||||||
res.json({ message: "Welcome to the application." });
|
res.json({ message: "Welcome to the application." });
|
||||||
});
|
});
|
||||||
|
|
||||||
require("./app/routes/routes.js")(app);
|
require("./app/routes/routes.js")(app);
|
||||||
app.listen({ port: 3000 }, async () => {
|
|
||||||
console.log('Server up on http://localhost:3000')
|
const PORT_NUMBER = process.env.SERVER_PORT
|
||||||
|
app.listen({ port: PORT_NUMBER }, async () => {
|
||||||
|
console.log('Server up on http://localhost:8000')
|
||||||
//await sequelize.authenticate()
|
//await sequelize.authenticate()
|
||||||
//console.log('Database Connected!')
|
|
||||||
})
|
})
|
||||||
Loading…
Reference in New Issue
Block a user