Merge branch 'master' of https://bitbucket.org/venbainformationtechnology/smc_cet_financials_backend
This commit is contained in:
commit
8c406641a2
448
app/controllers/master.controller.js
Normal file
448
app/controllers/master.controller.js
Normal file
@ -0,0 +1,448 @@
|
|||||||
|
//const db = require("../models");
|
||||||
|
//const Entities = db.tutorials;
|
||||||
|
//const Op = db.Sequelize.Op;
|
||||||
|
|
||||||
|
const { sequelize, Statementsmaster ,Sectionsmaster , Subsectionsmaster,Itemsmaster } = require('../models')
|
||||||
|
const { logMsg } = require('../services/logger.js');
|
||||||
|
|
||||||
|
|
||||||
|
//statementmaster
|
||||||
|
|
||||||
|
// Retrieve all statementmaster from the database.
|
||||||
|
exports.StatmentList = (req, res) => {
|
||||||
|
|
||||||
|
Statementsmaster.findAll({where : { is_active : 1 } })
|
||||||
|
.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.Insertstatement = (req, res) => {
|
||||||
|
// Create a statement
|
||||||
|
const statement = {
|
||||||
|
statement: req.body.statement,
|
||||||
|
is_active: req.body.is_active,
|
||||||
|
createdby: req.body.createdby,
|
||||||
|
updatedby: req.body.updatedby,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Save Tutorial in the database
|
||||||
|
Statementsmaster.create(statement)
|
||||||
|
.then(data => {
|
||||||
|
res.send(data);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
res.status(500).send({
|
||||||
|
message:
|
||||||
|
err.message || "Some error occurred while creating the statement."
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
// Post a statement
|
||||||
|
// insert datas into statementmaster table.
|
||||||
|
// exports.Insertstatement = (req, res) => {
|
||||||
|
|
||||||
|
// Statementsmaster.create({
|
||||||
|
// statement: req.body.statement,
|
||||||
|
// is_active: req.body.is_active,
|
||||||
|
// createdby: req.body.createdby,
|
||||||
|
// updatedby: req.body.updatedby,
|
||||||
|
// })
|
||||||
|
// .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" });
|
||||||
|
// });
|
||||||
|
// };
|
||||||
|
|
||||||
|
// updates datas into statementmaster table.
|
||||||
|
exports.Updatestatement = (req, res) => {
|
||||||
|
const id = req.params.id;
|
||||||
|
|
||||||
|
Statementsmaster.update(req.body, {
|
||||||
|
where: { id: id }
|
||||||
|
})
|
||||||
|
.then(num => {
|
||||||
|
if (num == 1) {
|
||||||
|
res.send({
|
||||||
|
message: "statement was updated successfully."
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
res.send({
|
||||||
|
message: `Cannot update statement with id=${id}. Maybe statement was not found or req.body is empty!`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
res.status(500).send({
|
||||||
|
message: "Error updating statement with id=" + id
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
//delete
|
||||||
|
exports.Deletestatement = (req, res) => {
|
||||||
|
const id = req.params.id;
|
||||||
|
|
||||||
|
Statementsmaster.update({ is_active : 0 },{
|
||||||
|
where: { id: id }
|
||||||
|
})
|
||||||
|
.then(num => {
|
||||||
|
if (num == 1) {
|
||||||
|
res.send({
|
||||||
|
message: "statement was deleted successfully!"
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
res.send({
|
||||||
|
message: `Cannot delete statement with id=${id}. Maybe statement was not found!`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
res.status(500).send({
|
||||||
|
message: "Could not delete statement with id=" + id
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//Sectionsmaster
|
||||||
|
|
||||||
|
// Retrieve all Sectionsmaster from the database.
|
||||||
|
exports.SectionList = (req, res) => {
|
||||||
|
|
||||||
|
Sectionsmaster.findAll({where : { is_active : 1 } })
|
||||||
|
.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 sections." ,'data': "No data" });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.Insertsection = (req, res) => {
|
||||||
|
// Create a section
|
||||||
|
const section = {
|
||||||
|
statement: req.body.statement,
|
||||||
|
section: req.body.section,
|
||||||
|
is_active: req.body.is_active,
|
||||||
|
createdby: req.body.createdby,
|
||||||
|
updatedby: req.body.updatedby,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Save section in the database
|
||||||
|
Sectionsmaster.create(section)
|
||||||
|
.then(data => {
|
||||||
|
res.send(data);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
res.status(500).send({
|
||||||
|
message:
|
||||||
|
err.message || "Some error occurred while creating the section."
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.Updatesection = (req, res) => {
|
||||||
|
const id = req.params.id;
|
||||||
|
|
||||||
|
Sectionsmaster.update(req.body, {
|
||||||
|
where: { id: id }
|
||||||
|
})
|
||||||
|
.then(num => {
|
||||||
|
if (num == 1) {
|
||||||
|
res.send({
|
||||||
|
message: "section was updated successfully."
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
res.send({
|
||||||
|
message: `Cannot update section with id=${id}. Maybe section was not found or req.body is empty!`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
res.status(500).send({
|
||||||
|
message: "Error updating section with id=" + id
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
//delete
|
||||||
|
exports.Deletesection = (req, res) => {
|
||||||
|
const id = req.params.id;
|
||||||
|
|
||||||
|
Sectionsmaster.update({ is_active : 0 },{
|
||||||
|
where: { id: id }
|
||||||
|
})
|
||||||
|
.then(num => {
|
||||||
|
if (num == 1) {
|
||||||
|
res.send({
|
||||||
|
message: "section was deleted successfully!"
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
res.send({
|
||||||
|
message: `Cannot delete section with id=${id}. Maybe section was not found!`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
res.status(500).send({
|
||||||
|
message: "Could not delete section with id=" + id
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Subsectionsmaster
|
||||||
|
// Retrieve all Subsectionsmaster from the database.
|
||||||
|
exports.SubsectionList = (req, res) => {
|
||||||
|
|
||||||
|
Subsectionsmaster.findAll({where : { is_active : 1 } })
|
||||||
|
.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 subsections." ,'data': "No data" });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.Insertsubsection = (req, res) => {
|
||||||
|
// Create a statement
|
||||||
|
const subsection = {
|
||||||
|
section: req.body.section,
|
||||||
|
subsection: req.body.subsection,
|
||||||
|
itemtext: req.body.itemtext,
|
||||||
|
is_active: req.body.is_active,
|
||||||
|
createdby: req.body.createdby,
|
||||||
|
updatedby: req.body.updatedby,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Save Tutorial in the database
|
||||||
|
Subsectionsmaster.create(subsection)
|
||||||
|
.then(data => {
|
||||||
|
res.send(data);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
res.status(500).send({
|
||||||
|
message:
|
||||||
|
err.message || "Some error occurred while creating the subsection."
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.Updatesubsection = (req, res) => {
|
||||||
|
const id = req.params.id;
|
||||||
|
|
||||||
|
Subsectionsmaster.update(req.body, {
|
||||||
|
where: { id: id }
|
||||||
|
})
|
||||||
|
.then(num => {
|
||||||
|
if (num == 1) {
|
||||||
|
res.send({
|
||||||
|
message: "subsection was updated successfully."
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
res.send({
|
||||||
|
message: `Cannot update subsection with id=${id}. Maybe subsection was not found or req.body is empty!`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
res.status(500).send({
|
||||||
|
message: "Error updating subsection with id=" + id
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
//delete
|
||||||
|
exports.Deletesubsection = (req, res) => {
|
||||||
|
const id = req.params.id;
|
||||||
|
|
||||||
|
Subsectionsmaster.update({ is_active : 0 },{
|
||||||
|
where: { id: id }
|
||||||
|
})
|
||||||
|
.then(num => {
|
||||||
|
if (num == 1) {
|
||||||
|
res.send({
|
||||||
|
message: "subsection was deleted successfully!"
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
res.send({
|
||||||
|
message: `Cannot delete subsection with id=${id}. Maybe subsection was not found!`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
res.status(500).send({
|
||||||
|
message: "Could not delete subsection with id=" + id
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//itemsmaster
|
||||||
|
// Retrieve all itemsmaster from the database.
|
||||||
|
exports.ItemList = (req, res) => {
|
||||||
|
|
||||||
|
Itemsmaster.findAll({where : { is_active : 1 } })
|
||||||
|
.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 items." ,'data': "No data" });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.Insertitem = (req, res) => {
|
||||||
|
// Create a item
|
||||||
|
const item = {
|
||||||
|
statement: req.body.statement,
|
||||||
|
section: req.body.section,
|
||||||
|
subsection: req.body.subsection,
|
||||||
|
itemtext: req.body.itemtext,
|
||||||
|
is_active: req.body.is_active,
|
||||||
|
pvt_ltd: req.body.pvt_ltd,
|
||||||
|
llp: req.body.llp,
|
||||||
|
others: req.body.others,
|
||||||
|
formula: req.body.formula,
|
||||||
|
is_calculated: req.body.is_calculated,
|
||||||
|
createdby: req.body.createdby,
|
||||||
|
updatedby: req.body.updatedby,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Save Tutorial in the database
|
||||||
|
Itemsmaster.create(item)
|
||||||
|
.then(data => {
|
||||||
|
res.send(data);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
res.status(500).send({
|
||||||
|
message:
|
||||||
|
err.message || "Some error occurred while creating the item."
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.Updateitem = (req, res) => {
|
||||||
|
const id = req.params.id;
|
||||||
|
|
||||||
|
Itemsmaster.update(req.body, {
|
||||||
|
where: { id: id }
|
||||||
|
})
|
||||||
|
.then(num => {
|
||||||
|
if (num == 1) {
|
||||||
|
res.send({
|
||||||
|
message: "item was updated successfully."
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
res.send({
|
||||||
|
message: `Cannot update item with id=${id}. Maybe item was not found or req.body is empty!`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
res.status(500).send({
|
||||||
|
message: "Error updating item with id=" + id
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
//delete
|
||||||
|
exports.Deleteitem = (req, res) => {
|
||||||
|
const id = req.params.id;
|
||||||
|
|
||||||
|
Itemsmaster.update({ is_active : 0 },{
|
||||||
|
where: { id: id }
|
||||||
|
})
|
||||||
|
.then(num => {
|
||||||
|
if (num == 1) {
|
||||||
|
res.send({
|
||||||
|
message: "item was deleted successfully!"
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
res.send({
|
||||||
|
message: `Cannot delete item with id=${id}. Maybe statement was not found!`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
res.status(500).send({
|
||||||
|
message: "Could not delete item with id=" + id
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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."
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -20,6 +20,12 @@ module.exports = (sequelize, DataTypes) => {
|
|||||||
section: { type: DataTypes.INTEGER },
|
section: { type: DataTypes.INTEGER },
|
||||||
subsection: { type: DataTypes.INTEGER },
|
subsection: { type: DataTypes.INTEGER },
|
||||||
itemtext: { type: DataTypes.STRING },
|
itemtext: { type: DataTypes.STRING },
|
||||||
|
is_active: { type: DataTypes.INTEGER },
|
||||||
|
pvtltd: { type: DataTypes.INTEGER },
|
||||||
|
llp: { type: DataTypes.INTEGER },
|
||||||
|
others: { type: DataTypes.INTEGER },
|
||||||
|
formula: { type: DataTypes.INTEGER },
|
||||||
|
is_calculated: { type: DataTypes.INTEGER },
|
||||||
createdby: { type: DataTypes.INTEGER },
|
createdby: { type: DataTypes.INTEGER },
|
||||||
updatedby: { type: DataTypes.INTEGER },
|
updatedby: { type: DataTypes.INTEGER },
|
||||||
|
|
||||||
|
|||||||
@ -17,6 +17,7 @@ module.exports = (sequelize, DataTypes) => {
|
|||||||
}
|
}
|
||||||
Statementsmaster.init(
|
Statementsmaster.init(
|
||||||
{
|
{
|
||||||
|
|
||||||
statement: { type: DataTypes.STRING },
|
statement: { type: DataTypes.STRING },
|
||||||
is_active: { type: DataTypes.INTEGER },
|
is_active: { type: DataTypes.INTEGER },
|
||||||
createdby: { type: DataTypes.INTEGER },
|
createdby: { type: DataTypes.INTEGER },
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
module.exports = app => {
|
module.exports = app => {
|
||||||
const request = require("request");
|
const request = require("request");
|
||||||
const financials = require("../controllers/financial.controller.js");
|
const financials = require("../controllers/financial.controller.js");
|
||||||
|
const master = require("../controllers/master.controller.js");
|
||||||
var router = require("express").Router();
|
var router = require("express").Router();
|
||||||
|
|
||||||
|
|
||||||
@ -12,6 +13,31 @@ module.exports = app => {
|
|||||||
router.get("/MenuList/:losid", financials.MenuList);
|
router.get("/MenuList/:losid", financials.MenuList);
|
||||||
|
|
||||||
|
|
||||||
|
//master.controller api's
|
||||||
|
// get statment master data
|
||||||
|
router.get("/StatmentsList", master.StatmentList);
|
||||||
|
router.post("/Insertstatement", master.Insertstatement);
|
||||||
|
router.put("/Updatestatement/:id", master.Updatestatement);
|
||||||
|
router.put("/Deletestatement/:id", master.Deletestatement);
|
||||||
|
|
||||||
|
router.get("/SectionList", master.SectionList);
|
||||||
|
router.post("/Insertsection", master.Insertsection);
|
||||||
|
router.put("/Updatesection/:id", master.Updatesection);
|
||||||
|
router.put("/Deletesection/:id", master.Deletesection);
|
||||||
|
|
||||||
|
router.get("/SubsectionList", master.SubsectionList);
|
||||||
|
router.post("/Insertsubsection", master.Insertsubsection);
|
||||||
|
router.put("/Updatesubsection/:id", master.Updatesubsection);
|
||||||
|
router.put("/Deletesubsection/:id", master.Deletesubsection);
|
||||||
|
|
||||||
|
router.get("/ItemList", master.ItemList);
|
||||||
|
router.post("/Insertitem", master.Insertitem);
|
||||||
|
router.put("/Updateitem/:id", master.Updateitem);
|
||||||
|
router.put("/Deleteitem/:id", master.Deleteitem);
|
||||||
|
|
||||||
|
//sample
|
||||||
|
//router.put("/:id", tutorials.update);
|
||||||
|
//router.delete("/:id", tutorials.delete);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user