Skeletion:GWM
This commit is contained in:
commit
0375343e82
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const {sequelize , Statementsmaster ,Sectionsmaster , Subsectionsmaster,Itemsmaster ,Fin_remarks} = require('../models')
|
const {sequelize , Statementsmaster ,Sectionsmaster , Subsectionsmaster,Itemsmaster ,Fin_remarks,Fin_masters_history} = require('../models')
|
||||||
const { logMsg } = require('../services/logger.js');
|
const { logMsg } = require('../services/logger.js');
|
||||||
|
|
||||||
|
|
||||||
@ -340,14 +340,14 @@ exports.ItemFilter = (req, res) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
exports.createRemarkss = (req, res) => {
|
exports.createRemarks = (req, res) => {
|
||||||
|
|
||||||
const req_array_data = req.body;
|
const req_array_data = req.body;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
req_array_data.forEach((value, key)=>{
|
req_array_data.forEach((value, key)=>{
|
||||||
if (value.hasOwnProperty("id"))
|
if (value.hasOwnProperty("id"))
|
||||||
{ console.log(value.is_active)
|
{
|
||||||
Fin_remarks.update({ is_active : 0 },{ where: { id: value.id }});
|
Fin_remarks.update({ is_active : 0 },{ where: { id: value.id }});
|
||||||
logMsg.info("updated is_active = 0 for primary key for Remarks: "+value.id);
|
logMsg.info("updated is_active = 0 for primary key for Remarks: "+value.id);
|
||||||
Fin_remarks.create({ "entity_id":value.entity_id,"itemid":value.itemid,"remarks":value.remarks,"is_active":value.is_active,"createdby":value.createdby })
|
Fin_remarks.create({ "entity_id":value.entity_id,"itemid":value.itemid,"remarks":value.remarks,"is_active":value.is_active,"createdby":value.createdby })
|
||||||
@ -356,7 +356,7 @@ exports.createRemarkss = (req, res) => {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
console.log(value.is_active)
|
|
||||||
Fin_remarks.create({ "entity_id":value.entity_id,"itemid":value.itemid,"remarks":value.remarks,"is_active":value.is_active,"createdby":value.createdby })
|
Fin_remarks.create({ "entity_id":value.entity_id,"itemid":value.itemid,"remarks":value.remarks,"is_active":value.is_active,"createdby":value.createdby })
|
||||||
logMsg.info("Created new Remarks entity_id: "+value.entity_id+"itemid:"+value.itemid);
|
logMsg.info("Created new Remarks entity_id: "+value.entity_id+"itemid:"+value.itemid);
|
||||||
|
|
||||||
@ -373,50 +373,61 @@ exports.createRemarkss = (req, res) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.createRemarks = (req, res) => {
|
exports.Historyapi = (req, res) => {
|
||||||
const obj = req.body
|
const reqq = req.query
|
||||||
if (obj.hasOwnProperty("id"))
|
//console.log(reqq)
|
||||||
|
let table_name;
|
||||||
|
if(req.query.table == "statement")
|
||||||
{
|
{
|
||||||
// update broken periods
|
table_name = "statementsmaster"
|
||||||
const Id = req.body.id
|
console.log(table_name)
|
||||||
Fin_remarks.update( {
|
|
||||||
entity_id: req.body.entity_id,
|
|
||||||
itemid: req.body.itemid,
|
|
||||||
remarks: req.body.remarks,
|
|
||||||
is_active: req.body.is_active,
|
|
||||||
createdby: req.body.createdby,
|
|
||||||
updatedby: req.body.updatedby,
|
|
||||||
} , { where: { id: Id } })
|
|
||||||
.then(data => {
|
|
||||||
res.send({'status':200,'message':"success",'data':data});
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
res.status(404).send({'status':404,
|
|
||||||
message: err.message || "Some error occurred while insertinging statements." ,'data': "No data"
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
if(req.query.table == "section")
|
||||||
{
|
{
|
||||||
// create broken period
|
table_name = "sectionsmaster"
|
||||||
Fin_remarks.create( {
|
|
||||||
entity_id: req.body.entity_id,
|
|
||||||
itemid: req.body.itemid,
|
|
||||||
remarks: req.body.remarks,
|
|
||||||
is_active: req.body.is_active,
|
|
||||||
createdby: req.body.createdby,
|
|
||||||
})
|
|
||||||
.then(data => {
|
|
||||||
res.send({'status':200,'message':"success",'data':data});
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
res.status(404).send({'status':404,
|
|
||||||
message: err.message || "Some error occurred while insertinging statements." ,'data': "No data"
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
if(req.query.table == "subsection")
|
||||||
|
{
|
||||||
|
table_name = "subsectionsmaster"
|
||||||
|
}
|
||||||
|
if(req.query.table == "item")
|
||||||
|
{
|
||||||
|
table_name = "itemsmaster"
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (reqq.hasOwnProperty("id"))
|
||||||
|
{ console.log(table_name)
|
||||||
|
const id = req.query.id
|
||||||
|
Fin_masters_history.findAll({where: { data_id: id , table_name: table_name }}).then(data => {
|
||||||
|
if(data.length)
|
||||||
|
{
|
||||||
|
res.send({'status':200,'message':"success",'data':data});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
res.send({'status':404,'message':"Failed",'data':'nodata'});
|
||||||
|
}
|
||||||
|
|
||||||
|
// logMsg.info("Success :"(data));
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
console.log(table_name)
|
||||||
|
Fin_masters_history.findAll({where: { table_name: table_name }}).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 inserting statements." ,'data': "No data"
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -505,5 +516,6 @@ exports.createRemarks = (req, res) => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
39
app/models/Fin_masters_history.js
Normal file
39
app/models/Fin_masters_history.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
'use strict'
|
||||||
|
const { Model } = require('sequelize')
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
class Fin_masters_history 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({ Model_name }) {
|
||||||
|
//this.hasMany(Model_name, { foreignKey: 'child_table_prim_key', as: 'child_tbl_name' })
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
Fin_masters_history.init(
|
||||||
|
{
|
||||||
|
|
||||||
|
table_name: { type: DataTypes.STRING },
|
||||||
|
column_name: { type: DataTypes.STRING },
|
||||||
|
data_id: { type: DataTypes.INTEGER },
|
||||||
|
old_data: { type: DataTypes.STRING },
|
||||||
|
new_data: { type: DataTypes.STRING },
|
||||||
|
user_id: { type: DataTypes.INTEGER },
|
||||||
|
user_name: { type: DataTypes.STRING },
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sequelize,
|
||||||
|
tableName: 'fin_masters_history',
|
||||||
|
modelName: 'Fin_masters_history',
|
||||||
|
createdAt: 'created_at',
|
||||||
|
updatedAt: false,
|
||||||
|
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return Fin_masters_history
|
||||||
|
}
|
||||||
@ -644,11 +644,83 @@ module.exports = app => {
|
|||||||
* description: success
|
* description: success
|
||||||
*/
|
*/
|
||||||
// get financials summary
|
// get financials summary
|
||||||
router.get("/ItemFilter/:section", master.ItemFilter);
|
router.get("/ItemFilter", master.ItemFilter);
|
||||||
|
|
||||||
router.post("/createRemarkss", master.createRemarkss);
|
/**
|
||||||
|
* @swagger
|
||||||
|
* definitions:
|
||||||
|
* remarks:
|
||||||
|
* type: object
|
||||||
|
* properties:
|
||||||
|
* entity_id:
|
||||||
|
* type: integer
|
||||||
|
* description: id of the entity
|
||||||
|
* example: 1
|
||||||
|
* itemid:
|
||||||
|
* type: integer
|
||||||
|
* description: id of the item
|
||||||
|
* example: 1
|
||||||
|
* remarks:
|
||||||
|
* type: string
|
||||||
|
* description: remarks
|
||||||
|
* example: testttttttttttttt
|
||||||
|
* is_active:
|
||||||
|
* type: integer
|
||||||
|
* description: the state of section(0 means inactive,1 means active)
|
||||||
|
* example: 1
|
||||||
|
* createdby:
|
||||||
|
* type: integer
|
||||||
|
* description: The person who created
|
||||||
|
* example: 1
|
||||||
|
* updatedby:
|
||||||
|
* type: integer
|
||||||
|
* description: The person who modified
|
||||||
|
* example: 1
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @swagger
|
||||||
|
* /api/createRemarks:
|
||||||
|
* post:
|
||||||
|
* summary: create Remarks
|
||||||
|
* description: create Remarks
|
||||||
|
* requestBody:
|
||||||
|
* content:
|
||||||
|
* application/json:
|
||||||
|
* schema:
|
||||||
|
* $ref: '#/definitions/remarks'
|
||||||
|
* responses:
|
||||||
|
* 200:
|
||||||
|
* description: item created succesfully
|
||||||
|
* 500:
|
||||||
|
* description: failure in creating item
|
||||||
|
*/
|
||||||
router.post("/createRemarks", master.createRemarks);
|
router.post("/createRemarks", master.createRemarks);
|
||||||
|
/**
|
||||||
|
* @swagger
|
||||||
|
* /api/Historyapi:
|
||||||
|
* get:
|
||||||
|
* summary: Historyapi
|
||||||
|
* description: Historyapi
|
||||||
|
* parameters:
|
||||||
|
* - in: query
|
||||||
|
* name: table
|
||||||
|
* schema:
|
||||||
|
* type: string
|
||||||
|
* required: true
|
||||||
|
* description: table name
|
||||||
|
* example: item
|
||||||
|
* - in: query
|
||||||
|
* name: id
|
||||||
|
* schema:
|
||||||
|
* type: integer
|
||||||
|
* required: true
|
||||||
|
* description: id
|
||||||
|
* example: 109
|
||||||
|
* responses:
|
||||||
|
* 200:
|
||||||
|
* description: success
|
||||||
|
*/
|
||||||
|
router.get("/Historyapi", master.Historyapi);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user