Surya: statement_type api

This commit is contained in:
surya 2021-09-09 19:36:52 +05:30
parent f5984d1ac3
commit 5b6c3b9111
3 changed files with 56 additions and 2 deletions

View File

@ -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" });
});
};

View File

@ -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
}

View File

@ -161,7 +161,7 @@ module.exports = app => {
router.get("/Statement_type", master.Statement_type);
/**