diff --git a/app/controllers/master.controller.js b/app/controllers/master.controller.js index 0002ad9..e9a0687 100644 --- a/app/controllers/master.controller.js +++ b/app/controllers/master.controller.js @@ -4,7 +4,7 @@ -const {sequelize , Statementsmaster ,Sectionsmaster , Subsectionsmaster,Itemsmaster ,Fin_remarks,Fin_masters_history} = require('../models') +const {sequelize , Statementsmaster ,Sectionsmaster , Subsectionsmaster,Itemsmaster ,Fin_remarks,Fin_masters_history,Statement_type} = require('../models') const { logMsg } = require('../services/logger.js'); @@ -431,6 +431,21 @@ exports.Historyapi = (req, res) => { }; +// Retrieve all statement types from the database. +exports.Statement_type = (req, res) => { + + Statement_type.findAll({where : { is_active : 1}}) + .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/models/Statement_type.js b/app/models/Statement_type.js new file mode 100644 index 0000000..3b79e5a --- /dev/null +++ b/app/models/Statement_type.js @@ -0,0 +1,39 @@ +'use strict' +const { Model } = require('sequelize') +const { logMsg } = require('../services/logger.js') +module.exports = (sequelize, DataTypes) => { + class Statement_type extends Model { + /** + * Helper method for defining associations. + * This method is not a part of Sequelize lifecycle. + * The `models/index` file will call this method automatically. + */ + // define association here + // static associate({ Sectionsmaster }) { + // this.hasMany(Sectionsmaster, { foreignKey: 'statement', as: 'sectionsmasterData' }) + // } + +//Sectionsmaster.hasMany(Subsectionsmaster, { foreignKey: 'section', as: 'subsectionsmaster' }) + + } + + Statement_type.init( + { + + statement_name: { type: DataTypes.STRING }, + is_active: { type: DataTypes.INTEGER }, + createdby: { type: DataTypes.INTEGER }, + updatedby: { type: DataTypes.INTEGER }, + + + }, + { + sequelize, + tableName: 'statement_type', + modelName: 'Statement_type', + + } + ) + // logMsg.info("Success-model ") + return Statement_type +} diff --git a/app/routes/routes.js b/app/routes/routes.js index d90a50a..577ed89 100644 --- a/app/routes/routes.js +++ b/app/routes/routes.js @@ -161,7 +161,7 @@ module.exports = app => { - + router.get("/Statement_type", master.Statement_type); /**