Surya:20-08-2021 GD changes

This commit is contained in:
surya 2021-08-21 17:25:27 +05:30
parent 9fa32abf87
commit 6aa911609f
3 changed files with 19 additions and 6 deletions

View File

@ -13,10 +13,11 @@ const { logMsg } = require('../services/logger.js');
// Retrieve all statements from the database. // Retrieve all statements from the database.
exports.StatementsList = async (req, res) => { exports.StatementsList = async (req, res) => {
await Statementsmaster.findAll({where : { is_active : 1 } }) await Statementsmaster.findAll()
.then(data => { .then(data => {
res.send({'status':200,'message':"success",'data':data}); res.send({'status':200,'message':"success",'data':data});
logMsg.info("Success :"(data)); logMsg.info("Success ");
}) })
.catch(err => { .catch(err => {
res.send({'status':404, res.send({'status':404,
@ -89,7 +90,8 @@ exports.Deletestatement = async (req, res) => {
// Retrieve all Sectionsmaster from the database. // Retrieve all Sectionsmaster from the database.
exports.SectionList = (req, res) => { exports.SectionList = (req, res) => {
Sectionsmaster.findAll({where : { is_active : 1 } }) //Sectionsmaster.findAll()
sequelize.query("SELECT sectionsmaster.id,sectionsmaster.statement as statement_id,statementsmaster.statement,sectionsmaster.section,sectionsmaster.is_active,sectionsmaster.createdby,sectionsmaster.createdon,sectionsmaster.updatedby,sectionsmaster.updatedon FROM sectionsmaster INNER JOIN statementsmaster ON sectionsmaster.statement=statementsmaster.id;")
.then(data => { .then(data => {
res.send({'status':200,'message':"success",'data':data}); res.send({'status':200,'message':"success",'data':data});
logMsg.info("Success :"(data)); logMsg.info("Success :"(data));
@ -166,7 +168,8 @@ exports.Deletesection = (req, res) => {
// Retrieve all Subsectionsmaster from the database. // Retrieve all Subsectionsmaster from the database.
exports.SubsectionList = (req, res) => { exports.SubsectionList = (req, res) => {
Subsectionsmaster.findAll({where : { is_active : 1 } }) //Subsectionsmaster.findAll()
sequelize.query("SELECT subsectionsmaster.id,subsectionsmaster.section as section_id,sectionsmaster.section,subsectionsmaster.subsection,subsectionsmaster.itemtext,subsectionsmaster.is_active,subsectionsmaster.createdby,subsectionsmaster.createdon,subsectionsmaster.updatedby,subsectionsmaster.updatedon FROM subsectionsmaster INNER JOIN sectionsmaster ON subsectionsmaster.section=sectionsmaster.id")
.then(data => { .then(data => {
res.send({'status':200,'message':"success",'data':data}); res.send({'status':200,'message':"success",'data':data});
logMsg.info("Success :"(data)); logMsg.info("Success :"(data));
@ -242,7 +245,8 @@ exports.Deletesubsection = (req, res) => {
// Retrieve all itemsmaster from the database. // Retrieve all itemsmaster from the database.
exports.ItemList = (req, res) => { exports.ItemList = (req, res) => {
Itemsmaster.findAll({where : { is_active : 1 } }) //Itemsmaster.findAll()
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 ,itemsmaster.itemtext,itemsmaster.is_active,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 => { .then(data => {
res.send({'status':200,'message':"success",'data':data}); res.send({'status':200,'message':"success",'data':data});
logMsg.info("Success :"(data)); logMsg.info("Success :"(data));

View File

@ -11,6 +11,15 @@ module.exports = (sequelize, DataTypes) => {
//static associate({ Model_name }) { //static associate({ Model_name }) {
//this.hasMany(Model_name, { foreignKey: 'child_table_prim_key', as: 'child_tbl_name' }) //this.hasMany(Model_name, { foreignKey: 'child_table_prim_key', as: 'child_tbl_name' })
//} //}
static associate({ Statementsmaster }) {
this.belongsTo(Statementsmaster, { foreignKey: 'id', as: 'statementsmasterData' })
}
static associate({ Subsectionsmaster }) {
this.hasMany(Subsectionsmaster, { foreignKey: 'section', as: 'subsectionsmasterData' })
}
static associate({ Sectionsmaster }) {
this.hasMany(Sectionsmaster, { foreignKey: 'statement', as: 'sectionsmasterData' })
}
} }

View File

@ -1,7 +1,7 @@
require('dotenv').config(); require('dotenv').config();
const express = require('express') const express = require('express')
const app = express() const app = express()
//it is used to clear cache
app.use(function(req, res, next) { app.use(function(req, res, next) {
res.set("Cache-Control", "no-cache, no-store, must-revalidate, max-age=0") res.set("Cache-Control", "no-cache, no-store, must-revalidate, max-age=0")
res.set("Pragma", "no-cache") res.set("Pragma", "no-cache")