From 9bebd5eda4ce390b61646f80c7af3bade95ac842 Mon Sep 17 00:00:00 2001 From: suseendhiran17 <58357088+suseendhiran17@users.noreply.github.com> Date: Fri, 24 Jun 2022 12:44:09 +0530 Subject: [PATCH] susee --- .../entity.applicant.controller.js | 112 ++++++++++++------ app/controllers/master.controller.js | 68 ++++++++++- app/controllers/test.controller.js | 2 +- app/models/ATNWrelatedInputMaster.js | 25 ++++ app/models/ATNWrelatedInputMasterValue.js | 25 ++++ app/models/ATNWrelatedInputs.js | 15 +-- app/models/ATNWrelationship.js | 26 ++++ app/models/OtherParameterMaster.js | 25 ++++ app/models/OtherParameterMasterValue.js | 25 ++++ app/models/OtherParameterRelationship.js | 26 ++++ app/routes/routes.js | 103 ++++++++++++++++ 11 files changed, 398 insertions(+), 54 deletions(-) create mode 100644 app/models/ATNWrelatedInputMaster.js create mode 100644 app/models/ATNWrelatedInputMasterValue.js create mode 100644 app/models/ATNWrelationship.js create mode 100644 app/models/OtherParameterMaster.js create mode 100644 app/models/OtherParameterMasterValue.js create mode 100644 app/models/OtherParameterRelationship.js diff --git a/app/controllers/entity.applicant.controller.js b/app/controllers/entity.applicant.controller.js index bbbc141..ba6d9c3 100644 --- a/app/controllers/entity.applicant.controller.js +++ b/app/controllers/entity.applicant.controller.js @@ -1,10 +1,10 @@ -const { sequelize , LoanDetail , EntityDetails , ApplicantsDetails , ApplicantsRelationship , ResidenceAddressDetails , PropertyOwnershipIncomeConsidered , DueDiligenceCheck , TradeReferences , CheckTypeMaster , EnquiriesAndDisbursements , PropertyAndLtv , ATNWrelatedInputs , OtherParameter , SalesPD} = require('../models') +const { sequelize , LoanDetail , EntityDetails , ApplicantsDetails , ApplicantsRelationship , ResidenceAddressDetails , PropertyOwnershipIncomeConsidered , DueDiligenceCheck , TradeReferences , CheckTypeMaster , EnquiriesAndDisbursements , PropertyAndLtv , ATNWrelatedInputs , OtherParameter , SalesPD , ATNWrelatedInputMaster ,ATNWrelationship , OtherParameterMaster ,OtherParameterMasterValue , OtherParameterRelationship } = require('../models') const { logMsg } = require('../services/logger.js'); -//create EntityDetails Api +//create EntityDetails , DueDiligenceCheck And ATNWrelatedInputs API exports.createEntityDetails = async (req, res) => { try @@ -27,10 +27,30 @@ exports.createEntityDetails = async (req, res) => }, 500); }) .catch(err => { logMsg.info("DueDiligenceCheckType Data Fetching Failed for EntityId= "+entityid+" Error= "+err); }); + + + + // ATNWrelatedInput data create + ATNWrelatedInputMaster.findAll({raw: true , where : {is_active : 1}}).then(async(ATNWrelatedInputMasterData) => + { + entityid = data.dataValues.id; + ATNWrelatedInputMasterData_arr = []; + for (const value of ATNWrelatedInputMasterData) + { + atnw_master_data = {entity_id:entityid , atnw_related_input_id:value.id , atnw_related_input:value.master_name}; + ATNWrelatedInputMasterData_arr.push(atnw_master_data); + } + setTimeout(() => { + ATNWrelatedInputs.bulkCreate(ATNWrelatedInputMasterData_arr) + .then(ATNWrelatedInputMasterData_arr =>{ logMsg.info("ATNWrelatedInputs Data Creation Success for EntityId= "+entityid); }) + .catch(err =>{ logMsg.info("ATNWrelatedInputs Data Creation Failed for EntityId= "+entityid+" Error= "+err); }); + }, 500); + }) + .catch(err => { logMsg.info("ATNWrelatedInputs Data Fetching Failed for EntityId= "+entityid+" Error= "+err); }); setTimeout(() => { res.send({'status':200,'message':"success",'data':data}); }, 1000); - + logMsg.info("Entity created successfully"); }) .catch(err => { @@ -692,42 +712,29 @@ exports.EntityApplicantNameList = async (req, res) => - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +//update updateATNWrelatedInputs Api +exports.updateATNWrelatedInputs = async (req, res) => +{ + try + { + id = req.body.id; + delete req.body.id; + // update value + ATNWrelatedInputs.update(req.body,{ where: { id: id }}).then(data => + { + res.send({'status':200,'message':"success",'data':data}); + + }) + .catch(err => { + res.send({'status':404, + message: err.message || "Some error occurred while retrieving statements." ,'data': "No data" }); + }); + + } catch(err) { + res.send({'status':404,message: err.message || "Some error occurred while inserting statements." ,'data': "No data" }); + } //end of try catch + +}; @@ -895,6 +902,33 @@ exports.updateLoanDetail = async (req, res) => } +//ATNWrelatedInputsList List Api +exports.ATNWrelatedInputsList = async (req, res) => +{ + try + { + ATNWrelatedInputs.findAll({raw: true , where : {entity_id : req.query.entity_id , is_active : 1}}).then(data => + { + if(data.length > 0) + { + res.send({'status':200,'message':"success",'data':data}); + } + else { + res.send({'status':404,'message':"failed",'data':"No data"}); + } + }) + .catch(err => { + res.send({'status':404, + message: err.message || "Some error occurred while retrieving statements." ,'data': "No data" }); + }); + + } catch(err) { + res.send({'status':404,message: err.message || "Some error occurred while inserting statements." ,'data': "No data" }); + } //end of try catch + +}; + + diff --git a/app/controllers/master.controller.js b/app/controllers/master.controller.js index 783f46d..2a252fd 100644 --- a/app/controllers/master.controller.js +++ b/app/controllers/master.controller.js @@ -1,5 +1,7 @@ const { sequelize,EntityApplicantMaster,StateMaster,CityMaster,PinMaster,ChecktypeCheckresultRelationMaster - ,DueDiligenceCheck,CheckResultMaster,CheckTypeMaster,LoanAndLtvMaster} = require('../models') + ,DueDiligenceCheck,CheckResultMaster,CheckTypeMaster,LoanAndLtvMaster , ATNWrelatedInputMaster , + ATNWrelatedInputMasterValues ,ATNWrelatedInputs, ATNWrelationship , + OtherParameterMaster ,OtherParameterMasterValue , OtherParameterRelationship} = require('../models') const { logMsg } = require('../services/logger.js'); @@ -127,9 +129,9 @@ const { logMsg } = require('../services/logger.js'); { try { - const storeData = await sequelize.query('SELECT checktype_checkresult_relation_master.check_type_id , checktype_checkresult_relation_master.check_result_id, check_type_master.value AS check_type, check_result_master.value AS check_result FROM checktype_checkresult_relation_master JOIN check_type_master ON checktype_checkresult_relation_master.check_type_id = check_type_master.id and check_type_master.is_active = 1JOIN check_result_master ON checktype_checkresult_relation_master.check_result_id = check_result_master.id and check_result_master.is_active = 1 where checktype_checkresult_relation_master.is_active = 1 ') - res.send({'status':200,'message':"success",'data':storeData - + sequelize.query('SELECT checktype_checkresult_relation_master.check_type_id , checktype_checkresult_relation_master.check_result_id, check_type_master.value AS check_type, check_result_master.value AS check_result FROM checktype_checkresult_relation_master JOIN check_type_master ON checktype_checkresult_relation_master.check_type_id = check_type_master.id and check_type_master.is_active = 1JOIN check_result_master ON checktype_checkresult_relation_master.check_result_id = check_result_master.id and check_result_master.is_active = 1 where checktype_checkresult_relation_master.is_active = 1 ') + .then((data)=> { + res.send({'status':200,'message':"success",'data':data}) }) .catch(err => { res.send({'status':404, @@ -217,6 +219,64 @@ const { logMsg } = require('../services/logger.js'); }; + + + // select atnwRelationMaster + exports.atnwRelationMaster = async (req, res) => + { + try + { + sequelize.query('SELECT atnw_relationship.atnw_master_id , atnw_relationship.atnw_value_id, atnw_related_input_master_name.master_name AS atnw_master_data , atnw_related_input_master_value.value AS atnw_master_value FROM atnw_relationship JOIN atnw_related_input_master_name ON atnw_relationship.atnw_master_id = atnw_related_input_master_name.id and atnw_related_input_master_name.is_active = 1 JOIN atnw_related_input_master_value ON atnw_relationship.atnw_value_id = atnw_related_input_master_value.id and atnw_related_input_master_value.is_active = 1 where atnw_relationship.is_active = 1 ') + .then((data)=> { + res.send({'status':200,'message':"success",'data':data}) + }) + .catch(err => { + res.send({'status':404, + message: err.message || "Some error occurred while fetching check result master data." ,'data': "No data" }); + }); + + } catch(err) { + res.send({'status':404, + message: err.message || "Some error occurred while fetching check result master data." ,'data': "No data" + }); + } //end of try catch + + + }; + + + + + // select atnwRelationMaster + exports.otherParameterMaster = async (req, res) => + { + try + { + sequelize.query('SELECT other_parameter_relationship.master_name_id , other_parameter_relationship.master_vaue_id, other_parameter_master.master_name AS other_parameter_master, other_parameter_master_value.value AS other_parameter_master_value FROM other_parameter_relationship JOIN other_parameter_master ON other_parameter_relationship.master_name_id = other_parameter_master.id and other_parameter_master.is_active = 1 JOIN other_parameter_master_value ON other_parameter_relationship.master_vaue_id = other_parameter_master_value.id and other_parameter_master_value.is_active = 1 where other_parameter_relationship.is_active = 1 ') + .then((data)=> { + res.send({'status':200,'message':"success",'data':data}) + }) + + .catch(err => { + res.send({'status':404, + message: err.message || "Some error occurred while fetching other Parameter Master data." ,'data': "No data" }); + }); + + } catch(err) { + res.send({'status':404, + message: err.message || "Some error occurred while fetching other Parameter Master data." ,'data': "No data" + }); + } //end of try catch + + + }; + + + + + + + // // select pin master data // exports.PinMasterData = async (req, res) => // { diff --git a/app/controllers/test.controller.js b/app/controllers/test.controller.js index 4d7e86b..f5153ac 100644 --- a/app/controllers/test.controller.js +++ b/app/controllers/test.controller.js @@ -23,7 +23,7 @@ exports.createModel = async (req, res) => var storeData = [ ]; var a = [ "money" , "int" , "numeric" , "real" ] var b = [ "nvarchar" ] - var c = [ "datetimeoffset" , "datetime"] + var c = [ "datetimeoffset" , "datetime" , "date" ] let query = "SELECT COLUMN_NAME, DATA_TYPE FROM mainapp_staging.INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='sales_PD';"; diff --git a/app/models/ATNWrelatedInputMaster.js b/app/models/ATNWrelatedInputMaster.js new file mode 100644 index 0000000..fa15e0f --- /dev/null +++ b/app/models/ATNWrelatedInputMaster.js @@ -0,0 +1,25 @@ +'use strict' +const { Model } = require('sequelize') +module.exports = (sequelize, DataTypes) => { + class ATNWrelatedInputMaster extends Model { + + } + ATNWrelatedInputMaster.init( + { + master_name: { type: DataTypes.STRING }, + createdby: { type: DataTypes.INTEGER }, + updatedby: { type: DataTypes.INTEGER }, + is_active: {type : DataTypes.INTEGER} + }, + { + sequelize, + tableName: 'atnw_related_input_master_name', + modelName: 'ATNWrelatedInputMaster', + } + ) + + + + + return ATNWrelatedInputMaster +} \ No newline at end of file diff --git a/app/models/ATNWrelatedInputMasterValue.js b/app/models/ATNWrelatedInputMasterValue.js new file mode 100644 index 0000000..30b6998 --- /dev/null +++ b/app/models/ATNWrelatedInputMasterValue.js @@ -0,0 +1,25 @@ +'use strict' +const { Model } = require('sequelize') +module.exports = (sequelize, DataTypes) => { + class ATNWrelatedInputMasterValues extends Model { + + } + ATNWrelatedInputMasterValues.init( + { + value: { type: DataTypes.STRING }, + createdby: { type: DataTypes.INTEGER }, + updatedby: { type: DataTypes.INTEGER }, + is_active: {type : DataTypes.INTEGER} + }, + { + sequelize, + tableName: 'atnw_related_input_master_value', + modelName: 'ATNWrelatedInputMasterValues', + } + ) + + + + + return ATNWrelatedInputMasterValues +} \ No newline at end of file diff --git a/app/models/ATNWrelatedInputs.js b/app/models/ATNWrelatedInputs.js index 4ca342b..cff6c28 100644 --- a/app/models/ATNWrelatedInputs.js +++ b/app/models/ATNWrelatedInputs.js @@ -6,15 +6,10 @@ module.exports = (sequelize, DataTypes) => { } ATNWrelatedInputs.init( { - property_ownership : { type: DataTypes.STRING }, - property_type : { type: DataTypes.STRING }, - property_used_in_business : { type: DataTypes.STRING }, - property_free : { type: DataTypes.STRING }, - property_in_the_name_of_applicant : { type: DataTypes.STRING }, - loan_obligated_in_cet : { type: DataTypes.STRING }, - property_created_last_eight_yr : { type: DataTypes.STRING }, - desktop_valuation : { type: DataTypes.STRING }, - final_amount_to_be_added : { type: DataTypes.STRING }, + entity_id : { type: DataTypes.INTEGER }, + atnw_related_input_id : { type: DataTypes.INTEGER }, + atnw_related_input : { type: DataTypes.STRING }, + atnw_related_input_value : { type: DataTypes.STRING }, createdAt : { type: DataTypes.DATE }, updatedAt : { type: DataTypes.DATE }, createdby : { type: DataTypes.INTEGER }, @@ -24,7 +19,7 @@ module.exports = (sequelize, DataTypes) => { }, { sequelize, - tableName: 'ATNW_related_inputs', + tableName: 'atnw_related_inputs', modelName: 'ATNWrelatedInputs', } ) diff --git a/app/models/ATNWrelationship.js b/app/models/ATNWrelationship.js new file mode 100644 index 0000000..0822296 --- /dev/null +++ b/app/models/ATNWrelationship.js @@ -0,0 +1,26 @@ +'use strict' +const { Model } = require('sequelize') +module.exports = (sequelize, DataTypes) => { + class ATNWrelationship extends Model { + + } + ATNWrelationship.init( + { + atnw_master_id: { type: DataTypes.INTEGER }, + atnw_value_id: { type: DataTypes.INTEGER }, + createdby: { type: DataTypes.INTEGER }, + updatedby: { type: DataTypes.INTEGER }, + is_active: {type : DataTypes.INTEGER} + }, + { + sequelize, + tableName: 'atnw_relationship', + modelName: 'ATNWrelationship', + } + ) + + + + + return ATNWrelationship +} \ No newline at end of file diff --git a/app/models/OtherParameterMaster.js b/app/models/OtherParameterMaster.js new file mode 100644 index 0000000..028136c --- /dev/null +++ b/app/models/OtherParameterMaster.js @@ -0,0 +1,25 @@ +'use strict' +const { Model } = require('sequelize') +module.exports = (sequelize, DataTypes) => { + class OtherParameterMaster extends Model { + + } + OtherParameterMaster.init( + { + master_name: { type: DataTypes.STRING }, + createdby: { type: DataTypes.INTEGER }, + updatedby: { type: DataTypes.INTEGER }, + is_active: {type : DataTypes.INTEGER} + }, + { + sequelize, + tableName: 'other_parameter_master', + modelName: 'OtherParameterMaster', + } + ) + + + + + return OtherParameterMaster +} \ No newline at end of file diff --git a/app/models/OtherParameterMasterValue.js b/app/models/OtherParameterMasterValue.js new file mode 100644 index 0000000..b6fc7ca --- /dev/null +++ b/app/models/OtherParameterMasterValue.js @@ -0,0 +1,25 @@ +'use strict' +const { Model } = require('sequelize') +module.exports = (sequelize, DataTypes) => { + class OtherParameterMasterValue extends Model { + + } + OtherParameterMasterValue.init( + { + value: { type: DataTypes.STRING }, + createdby: { type: DataTypes.INTEGER }, + updatedby: { type: DataTypes.INTEGER }, + is_active: {type : DataTypes.INTEGER} + }, + { + sequelize, + tableName: 'other_parameter_master_value', + modelName: 'OtherParameterMasterValue', + } + ) + + + + + return OtherParameterMasterValue +} \ No newline at end of file diff --git a/app/models/OtherParameterRelationship.js b/app/models/OtherParameterRelationship.js new file mode 100644 index 0000000..0500075 --- /dev/null +++ b/app/models/OtherParameterRelationship.js @@ -0,0 +1,26 @@ +'use strict' +const { Model } = require('sequelize') +module.exports = (sequelize, DataTypes) => { + class OtherParameterRelationship extends Model { + + } + OtherParameterRelationship.init( + { + master_name_id: { type: DataTypes.INTEGER }, + master_vaue_id: { type: DataTypes.INTEGER }, + createdby: { type: DataTypes.INTEGER }, + updatedby: { type: DataTypes.INTEGER }, + is_active: {type : DataTypes.INTEGER} + }, + { + sequelize, + tableName: 'other_parameter_relationship', + modelName: 'OtherParameterRelationship', + } + ) + + + + + return OtherParameterRelationship +} \ No newline at end of file diff --git a/app/routes/routes.js b/app/routes/routes.js index a1a80e1..1747588 100644 --- a/app/routes/routes.js +++ b/app/routes/routes.js @@ -2245,6 +2245,109 @@ router.post("/updateLoanDetail", Entitycontroller.updateLoanDetail); */ router.get("/loanAndLtvMaster", Mastercontroller.loanAndLtvMaster); + +// CheckResultMaster select api + +/** +* @swagger +* /api/atnwRelationMaster: +* get: +* summary: atnw Relation Master data Api +* description: atnw Relation Master data Api +* responses: +* 200: +* description: success +*/ +router.get("/atnwRelationMaster", Mastercontroller.atnwRelationMaster); + + +// Update DueDiligenceCheck Details +/** +* @swagger +* definitions: +* updateATNWrelatedInputs: +* type: object +* properties: +* id: +* type: integer +* description: +* example: 1 +* entity_id: +* type: integer +* description: +* example: 1 +* atnw_related_input_id: +* type: integer +* description: +* example: 1 +* atnw_related_input: +* type: string +* description: +* example: property_own_doc_avail +* atnw_related_input_value: +* type: string +* description: +* example: Yes +* updatedby: +* type: integer +* description: +* example: 1 +*/ +/** +* @swagger +* /api/updateATNWrelatedInputs: +* post: +* summary: update updateATNWrelatedInputs Details +* description: update updateATNWrelatedInputs +* requestBody: +* content: +* application/json: +* schema: +* $ref: '#/definitions/updateATNWrelatedInputs' +* responses: +* 200: +* description: New updated updateATNWrelatedInputs +* 500: +* description: failure in updating updateATNWrelatedInputs +*/ +router.post("/updateATNWrelatedInputs", Entitycontroller.updateATNWrelatedInputs); + + +// Due Diligence Check Details List Api +/** +* @swagger +* /api/atnwrelatedInputsList: +* get: +* summary: atnw related Inputs List +* description: Get atnw related Inputs List by sending entity id(Primery key) +* parameters: +* - in: query +* name: entity_id +* schema: +* type: integer +* required: true +* description: id of the entity Details (primart key of entity) +* example: 1 +* responses: +* 200: +* description: success +*/ +router.get("/atnwrelatedInputsList", Entitycontroller.ATNWrelatedInputsList); + +// otherParameterMaster select api + +/** +* @swagger +* /api/otherParameterMaster: +* get: +* summary: other Parameter Master data Api +* description: other Parameter Master data Api +* responses: +* 200: +* description: success +*/ +router.get("/otherParameterMaster", Mastercontroller.otherParameterMaster); + // routes started here app.use('/api', router); };