Surya: statement_type api
This commit is contained in:
parent
f5984d1ac3
commit
5b6c3b9111
@ -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" });
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
39
app/models/Statement_type.js
Normal file
39
app/models/Statement_type.js
Normal 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
|
||||
}
|
||||
@ -161,7 +161,7 @@ module.exports = app => {
|
||||
|
||||
|
||||
|
||||
|
||||
router.get("/Statement_type", master.Statement_type);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user