Surya:route changes
This commit is contained in:
parent
fc948852fc
commit
227d929efe
@ -9,7 +9,7 @@ const { logMsg } = require('../services/logger.js');
|
||||
//statementmaster
|
||||
|
||||
// Retrieve all statements from the database.
|
||||
exports.StatmentList = (req, res) => {
|
||||
exports.StatementsList = (req, res) => {
|
||||
|
||||
Statementsmaster.findAll({where : { is_active : 1 } })
|
||||
.then(data => {
|
||||
@ -17,7 +17,7 @@ exports.StatmentList = (req, res) => {
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({'status':404,
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while retrieving statements." ,'data': "No data" });
|
||||
});
|
||||
};
|
||||
@ -52,18 +52,12 @@ exports.Updatestatement = (req, res) => {
|
||||
Statementsmaster.update(req.body, {
|
||||
where: { id: id }
|
||||
})
|
||||
.then(num => {
|
||||
if (num == 1) {
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
} else {
|
||||
res.send({
|
||||
message: `Cannot update statement with id= ${id}. Maybe statement was not found or req.body is empty!`
|
||||
});
|
||||
}
|
||||
})
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({'status':404,
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
@ -76,21 +70,15 @@ exports.Deletestatement = (req, res) => {
|
||||
Statementsmaster.update({ is_active : 0 },{
|
||||
where: { id: id }
|
||||
})
|
||||
.then(num => {
|
||||
if (num == 1) {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
} else {
|
||||
res.send({
|
||||
message: `Cannot delete statement with id=${id}. Maybe statement was not found!`
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({'status':404,
|
||||
message: err.message || "Some error occurred while Deletiing statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
.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 updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@ -105,7 +93,7 @@ exports.SectionList = (req, res) => {
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({'status':404,
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while retrieving sections." ,'data': "No data" });
|
||||
});
|
||||
};
|
||||
@ -127,7 +115,7 @@ exports.Insertsection = (req, res) => {
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({'status':404,
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while insertinging sectino." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
@ -139,21 +127,15 @@ exports.Updatesection = (req, res) => {
|
||||
Sectionsmaster.update(req.body, {
|
||||
where: { id: id }
|
||||
})
|
||||
.then(num => {
|
||||
if (num == 1) {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
} 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({'status':404,
|
||||
message: err.message || "Some error occurred while updating sectinos." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
.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 updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
//delete
|
||||
@ -163,21 +145,17 @@ exports.Deletesection = (req, res) => {
|
||||
Sectionsmaster.update({ is_active : 0 },{
|
||||
where: { id: id }
|
||||
})
|
||||
.then(num => {
|
||||
if (num == 1) {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
} else {
|
||||
res.send({
|
||||
message: `Cannot delete section with id=${id}. Maybe section was not found!`
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({'status':404,
|
||||
message: err.message || "Some error occurred while Deleting statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
|
||||
.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 updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@ -192,7 +170,7 @@ exports.SubsectionList = (req, res) => {
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({'status':404,
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while retrieving subsections." ,'data': "No data" });
|
||||
});
|
||||
};
|
||||
@ -215,7 +193,7 @@ exports.Insertsubsection = (req, res) => {
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({'status':404,
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while insertinging subsection." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
@ -227,21 +205,16 @@ exports.Updatesubsection = (req, res) => {
|
||||
Subsectionsmaster.update(req.body, {
|
||||
where: { id: id }
|
||||
})
|
||||
.then(num => {
|
||||
if (num == 1) {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
} 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({'status':404,
|
||||
message: err.message || "Some error occurred while updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
.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 updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
//delete
|
||||
@ -251,21 +224,15 @@ exports.Deletesubsection = (req, res) => {
|
||||
Subsectionsmaster.update({ is_active : 0 },{
|
||||
where: { id: id }
|
||||
})
|
||||
.then(num => {
|
||||
if (num == 1) {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
} else {
|
||||
res.send({
|
||||
message: `Cannot delete subsection with id=${id}. Maybe subsection was not found!`
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({'status':404,
|
||||
message: err.message || "Some error occurred while updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
.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 updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@ -279,7 +246,7 @@ exports.ItemList = (req, res) => {
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({'status':404,
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while retrieving items." ,'data': "No data" });
|
||||
});
|
||||
};
|
||||
@ -308,7 +275,7 @@ exports.Insertitem = (req, res) => {
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({'status':404,
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while insertinging items." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
@ -320,21 +287,15 @@ exports.Updateitem = (req, res) => {
|
||||
Itemsmaster.update(req.body, {
|
||||
where: { id: id }
|
||||
})
|
||||
.then(num => {
|
||||
if (num == 1) {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
} 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({'status':404,
|
||||
message: err.message || "Some error occurred while updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
.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 updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
//delete
|
||||
@ -344,21 +305,15 @@ exports.Deleteitem = (req, res) => {
|
||||
Itemsmaster.update({ is_active : 0 },{
|
||||
where: { id: id }
|
||||
})
|
||||
.then(num => {
|
||||
if (num == 1) {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
} else {
|
||||
res.send({
|
||||
message: `Cannot delete item with id=${id}. Maybe statement was not found!`
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({'status':404,
|
||||
message: err.message || "Some error occurred while updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
.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 updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ module.exports = app => {
|
||||
* 200:
|
||||
* description: Returns a mysterious string.
|
||||
*/
|
||||
router.get("/StatementsList", master.StatmentList);
|
||||
router.get("/StatementsList", master.StatementsList);
|
||||
/**
|
||||
* @openapi
|
||||
* /api/Insertstatement:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user