susee
This commit is contained in:
parent
afa816d7dc
commit
b03096711f
@ -1,6 +1,7 @@
|
||||
const { sequelize,Test , AdjustableTang , PolicyParameterMaster } = require('../models')
|
||||
const { logMsg } = require('../services/logger.js');
|
||||
|
||||
|
||||
exports.Welcome = (req, res) =>
|
||||
{
|
||||
try
|
||||
@ -18,49 +19,66 @@ exports.Welcome = (req, res) =>
|
||||
};
|
||||
|
||||
|
||||
exports.createModel = async (req, res) =>
|
||||
exports.json = (req, res) =>
|
||||
{
|
||||
// var storeData = [ ];
|
||||
// var a = [ "money" , "int" , "numeric" , "real" ]
|
||||
// var b = [ "nvarchar" ]
|
||||
// var c = [ "datetimeoffset" , "datetime" , "date"]
|
||||
|
||||
|
||||
// let query = "SELECT COLUMN_NAME, DATA_TYPE FROM credit_policy_staging.INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='turnover_for_female_applicant';";
|
||||
// storeData = await sequelize.query(query)
|
||||
// storeData.forEach(async(element) => {
|
||||
try
|
||||
{
|
||||
PolicyParameterMaster.findAll({ where : { id : 48}})
|
||||
.then(data=>
|
||||
{
|
||||
const resP = JSON.parse(data[0].rules)
|
||||
pro_type = 'Residential';
|
||||
pro_val = 'Rented';
|
||||
const { Engine } = require('json-rules-engine')
|
||||
let engine = new Engine()
|
||||
engine.addRule({
|
||||
conditions: {
|
||||
any: [{
|
||||
all: [{
|
||||
fact: 'prop_type' ,
|
||||
operator: 'in',
|
||||
value : Object.keys(resP)
|
||||
}, {
|
||||
fact: 'prop_val' ,
|
||||
operator: 'in',
|
||||
value: Object.keys(resP[pro_type])
|
||||
}]
|
||||
}]
|
||||
},
|
||||
event: {
|
||||
type: 'Norms',
|
||||
params: {
|
||||
message: resP.Residential.Rented
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
let facts = { prop_type: pro_type , prop_val: pro_val }
|
||||
// Run the engine to evaluate
|
||||
engine.run(facts)
|
||||
.then(({ events }) =>
|
||||
{
|
||||
events.map(event => console.log(event.params.message))
|
||||
})
|
||||
|
||||
// Object.values(element).forEach( async (element) => {
|
||||
// if ( a.includes(element.DATA_TYPE)) {
|
||||
// console.log( element.COLUMN_NAME, ": { type: DataTypes.INTEGER },");
|
||||
// }
|
||||
// if ( b.includes(element.DATA_TYPE)) {
|
||||
// console.log( element.COLUMN_NAME, ": { type: DataTypes.STRING },");
|
||||
// }
|
||||
// if ( c.includes(element.DATA_TYPE)) {
|
||||
// console.log( element.COLUMN_NAME, ": { type: DataTypes.DATE },");
|
||||
// }
|
||||
// });
|
||||
|
||||
})
|
||||
.catch(err=> { res.send(err)})
|
||||
} catch(err) {
|
||||
res.status(500).send({'status':404,
|
||||
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
|
||||
}); } //end of try catch
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// });
|
||||
// (update_subValue_data_element,{ where: { id: id }})
|
||||
const json = '{"Residential" : { "Self Occupied" : "400","Rented" : "400","Vacant" : "400","Mixed Use" : "400"},"Commercial" : { "Self Occupied" : "200", "Rented" : "200","Vacant" : "Not Allowed","Mixed Use" : "200"},"Industrial" : { "Self Occupied" : "800","Rented" : "800","Vacant" : "Not Allowed","Mixed Use" : "Not Allowed"},"Agricultural" : { "Self Occupied" : "Not Allowed","Rented" : "Not Allowed","Vacant" : "Not Allowed","Mixed Use" : "Not Allowed"}}'
|
||||
|
||||
function isJson(str) {
|
||||
try {
|
||||
JSON.parse(str);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
console.log( isJson(json) )
|
||||
PolicyParameterMaster.update({ rules : json } ,{ where : { id : 73 } }).then(data=> { res.send(data)}).catch(err=>{res.send(err)})
|
||||
// PolicyParameterMaster.findAll({ where : { id : 48}}).then(data=> {
|
||||
// res.send(data[0].rules)
|
||||
// }).catch(err=>{res.send(err)})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -9,7 +9,10 @@ module.exports = (sequelize, DataTypes) => {
|
||||
{
|
||||
section_id : { type: DataTypes.INTEGER },
|
||||
parameter : { type: DataTypes.STRING },
|
||||
rules : { type: DataTypes.STRING },
|
||||
rules : { type: DataTypes.STRING },
|
||||
master_key : { type: DataTypes.INTEGER },
|
||||
data : { type: DataTypes.INTEGER },
|
||||
json : { type: DataTypes.INTEGER },
|
||||
is_active : { type: DataTypes.INTEGER },
|
||||
createdAt : { type: DataTypes.DATE },
|
||||
updatedAt : { type: DataTypes.DATE },
|
||||
|
||||
@ -22,6 +22,8 @@ module.exports = app => {
|
||||
*/
|
||||
router.get("/demo", Mycontroller.Welcome);
|
||||
|
||||
router.get("/json", Mycontroller.json);
|
||||
|
||||
|
||||
// Parameter Maste rData select api
|
||||
|
||||
|
||||
81
package-lock.json
generated
81
package-lock.json
generated
@ -13,6 +13,7 @@
|
||||
"cors": "^2.8.5",
|
||||
"dotenv": "^10.0.0",
|
||||
"express": "^4.17.1",
|
||||
"json-rules-engine": "^6.1.2",
|
||||
"log4js": "^6.3.0",
|
||||
"mssql": "^7.2.0",
|
||||
"request": "^2.88.2",
|
||||
@ -1340,6 +1341,14 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/clone": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz",
|
||||
"integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==",
|
||||
"engines": {
|
||||
"node": ">=0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/clone-response": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz",
|
||||
@ -1783,6 +1792,11 @@
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/eventemitter2": {
|
||||
"version": "6.4.6",
|
||||
"resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-6.4.6.tgz",
|
||||
"integrity": "sha512-OHqo4wbHX5VbvlbB6o6eDwhYmiTjrpWACjF8Pmof/GTD6rdBNdZFNck3xlhqOiQFGCOoq3uzHvA0cQpFHIGVAQ=="
|
||||
},
|
||||
"node_modules/events": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz",
|
||||
@ -2248,6 +2262,11 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/hash-it": {
|
||||
"version": "5.0.2",
|
||||
"resolved": "https://registry.npmjs.org/hash-it/-/hash-it-5.0.2.tgz",
|
||||
"integrity": "sha512-csU3E/a9QEmEgPPxoShVuMcFWM329IGioEPRvYVBv3r5BFrU8pCfnk3jGEVvriAcwqd+nl6KsNhPPjg8MUzkhQ=="
|
||||
},
|
||||
"node_modules/http-cache-semantics": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz",
|
||||
@ -2650,6 +2669,18 @@
|
||||
"integrity": "sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg=",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/json-rules-engine": {
|
||||
"version": "6.1.2",
|
||||
"resolved": "https://registry.npmjs.org/json-rules-engine/-/json-rules-engine-6.1.2.tgz",
|
||||
"integrity": "sha512-+rtKuJ33HAvFywL9broh42FA9hkZNmS0l1DmgjP7nfGJ9E2i2IsfNH0BcXjyXianp/bXAyYlsSv308AfTuvBwQ==",
|
||||
"dependencies": {
|
||||
"clone": "^2.1.2",
|
||||
"eventemitter2": "^6.4.4",
|
||||
"hash-it": "^5.0.0",
|
||||
"jsonpath-plus": "^5.0.7",
|
||||
"lodash.isobjectlike": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/json-schema": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz",
|
||||
@ -2676,6 +2707,14 @@
|
||||
"graceful-fs": "^4.1.6"
|
||||
}
|
||||
},
|
||||
"node_modules/jsonpath-plus": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/jsonpath-plus/-/jsonpath-plus-5.1.0.tgz",
|
||||
"integrity": "sha512-890w2Pjtj0iswAxalRlt2kHthi6HKrXEfZcn+ZNZptv7F3rUGIeDuZo+C+h4vXBHLEsVjJrHeCm35nYeZLzSBQ==",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/jsonwebtoken": {
|
||||
"version": "8.5.1",
|
||||
"resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz",
|
||||
@ -2826,6 +2865,11 @@
|
||||
"resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz",
|
||||
"integrity": "sha1-POdoEMWSjQM1IwGsKHMX8RwLH/w="
|
||||
},
|
||||
"node_modules/lodash.isobjectlike": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/lodash.isobjectlike/-/lodash.isobjectlike-4.0.0.tgz",
|
||||
"integrity": "sha512-bbRt0Dief0yqjkTgpvzisSxnsmY3ZgVJvokHL30UE+ytsvnpNfiNaCJL4XBEWek8koQmrwZidBHb7coXC5vXlA=="
|
||||
},
|
||||
"node_modules/lodash.isplainobject": {
|
||||
"version": "4.0.6",
|
||||
"resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz",
|
||||
@ -5982,6 +6026,11 @@
|
||||
"integrity": "sha512-y4coMcylgSCdVinjiDBuR8PCC2bLjyGTwEmPb9NHR/QaNU6EUOXcTY/s6VjGMD6ENSEaeQYHCY0GNGS5jfMwPw==",
|
||||
"dev": true
|
||||
},
|
||||
"clone": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz",
|
||||
"integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w=="
|
||||
},
|
||||
"clone-response": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz",
|
||||
@ -6332,6 +6381,11 @@
|
||||
"resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
|
||||
"integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ=="
|
||||
},
|
||||
"eventemitter2": {
|
||||
"version": "6.4.6",
|
||||
"resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-6.4.6.tgz",
|
||||
"integrity": "sha512-OHqo4wbHX5VbvlbB6o6eDwhYmiTjrpWACjF8Pmof/GTD6rdBNdZFNck3xlhqOiQFGCOoq3uzHvA0cQpFHIGVAQ=="
|
||||
},
|
||||
"events": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz",
|
||||
@ -6689,6 +6743,11 @@
|
||||
"integrity": "sha512-UqBRqi4ju7T+TqGNdqAO0PaSVGsDGJUBQvk9eUWNGRY1CFGDzYhLWoM7JQEemnlvVcv/YEmc2wNW8BC24EnUsw==",
|
||||
"dev": true
|
||||
},
|
||||
"hash-it": {
|
||||
"version": "5.0.2",
|
||||
"resolved": "https://registry.npmjs.org/hash-it/-/hash-it-5.0.2.tgz",
|
||||
"integrity": "sha512-csU3E/a9QEmEgPPxoShVuMcFWM329IGioEPRvYVBv3r5BFrU8pCfnk3jGEVvriAcwqd+nl6KsNhPPjg8MUzkhQ=="
|
||||
},
|
||||
"http-cache-semantics": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz",
|
||||
@ -6977,6 +7036,18 @@
|
||||
"integrity": "sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg=",
|
||||
"dev": true
|
||||
},
|
||||
"json-rules-engine": {
|
||||
"version": "6.1.2",
|
||||
"resolved": "https://registry.npmjs.org/json-rules-engine/-/json-rules-engine-6.1.2.tgz",
|
||||
"integrity": "sha512-+rtKuJ33HAvFywL9broh42FA9hkZNmS0l1DmgjP7nfGJ9E2i2IsfNH0BcXjyXianp/bXAyYlsSv308AfTuvBwQ==",
|
||||
"requires": {
|
||||
"clone": "^2.1.2",
|
||||
"eventemitter2": "^6.4.4",
|
||||
"hash-it": "^5.0.0",
|
||||
"jsonpath-plus": "^5.0.7",
|
||||
"lodash.isobjectlike": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"json-schema": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz",
|
||||
@ -7001,6 +7072,11 @@
|
||||
"universalify": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"jsonpath-plus": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/jsonpath-plus/-/jsonpath-plus-5.1.0.tgz",
|
||||
"integrity": "sha512-890w2Pjtj0iswAxalRlt2kHthi6HKrXEfZcn+ZNZptv7F3rUGIeDuZo+C+h4vXBHLEsVjJrHeCm35nYeZLzSBQ=="
|
||||
},
|
||||
"jsonwebtoken": {
|
||||
"version": "8.5.1",
|
||||
"resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz",
|
||||
@ -7142,6 +7218,11 @@
|
||||
"resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz",
|
||||
"integrity": "sha1-POdoEMWSjQM1IwGsKHMX8RwLH/w="
|
||||
},
|
||||
"lodash.isobjectlike": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/lodash.isobjectlike/-/lodash.isobjectlike-4.0.0.tgz",
|
||||
"integrity": "sha512-bbRt0Dief0yqjkTgpvzisSxnsmY3ZgVJvokHL30UE+ytsvnpNfiNaCJL4XBEWek8koQmrwZidBHb7coXC5vXlA=="
|
||||
},
|
||||
"lodash.isplainobject": {
|
||||
"version": "4.0.6",
|
||||
"resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz",
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
"cors": "^2.8.5",
|
||||
"dotenv": "^10.0.0",
|
||||
"express": "^4.17.1",
|
||||
"json-rules-engine": "^6.1.2",
|
||||
"log4js": "^6.3.0",
|
||||
"mssql": "^7.2.0",
|
||||
"request": "^2.88.2",
|
||||
|
||||
@ -56,7 +56,7 @@ require("./app/routes/routes.js")(app);
|
||||
|
||||
const PORT_NUMBER = process.env.SERVER_PORT
|
||||
app.listen({ port: PORT_NUMBER }, async () => {
|
||||
console.log('Server up on http://localhost:8080')
|
||||
console.log('Server up on http://localhost:'+PORT_NUMBER)
|
||||
|
||||
//await sequelize.authenticate()
|
||||
})
|
||||
|
||||
@ -14,6 +14,21 @@
|
||||
"date": 1656658989456,
|
||||
"name": "storage\\log\\msg.log.2022-07-01",
|
||||
"hash": "a401d882f6ca8da2a15b684623338e06"
|
||||
},
|
||||
{
|
||||
"date": 1657079479760,
|
||||
"name": "storage\\log\\msg.log.2022-07-06",
|
||||
"hash": "8f9c9922f35871897c579b0c2cbabc71"
|
||||
},
|
||||
{
|
||||
"date": 1657253497697,
|
||||
"name": "storage\\log\\msg.log.2022-07-08",
|
||||
"hash": "d985a2e86105fad5abe24854420a6323"
|
||||
},
|
||||
{
|
||||
"date": 1657592050655,
|
||||
"name": "storage\\log\\msg.log.2022-07-12",
|
||||
"hash": "a40aed0c41e0501419325f26634103a9"
|
||||
}
|
||||
],
|
||||
"hashType": "md5"
|
||||
|
||||
@ -5,3 +5,5 @@
|
||||
{"level":"info","message":"Master Data List api call Success"}
|
||||
{"level":"info","message":"Executing (default): SELECT [id], [property_ownership_document_available], [type_of_property], [property_used_in_business], [property_free_loan_taken], [property_in_the_name_of_applicant], [loan_obligated_in_cet], [property_created_in_last_eight_yr], [value_to_be_considered], [mv_to_be_added_to_atnw], [final_value_considered], [is_active], [createdby], [updatedby], [createdAt], [updatedAt] FROM [adjustable_tangible_networth_property_valuation] AS [AdjustableTang] WHERE [AdjustableTang].[is_active] = 1;"}
|
||||
{"level":"info","message":"Master Data List api call Success"}
|
||||
{"level":"info","message":"Executing (default): SELECT section_master.section , policy_parameter_master.parameter , policy_parameter_master.rules FROM policy_parameter_master JOIN section_master ON policy_parameter_master.section_id = section_master.id and section_master.is_active = 1 where policy_parameter_master.is_active = 1"}
|
||||
{"level":"info","message":"Master Data List api call Success"}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user