From 1d86263f94ff566d6a1aab7453c5a8ecebb3ab81 Mon Sep 17 00:00:00 2001 From: sriramv Date: Wed, 16 Aug 2023 11:41:22 +0530 Subject: [PATCH] entity_name:GWM --- app/controllers/loan.details.controller.js | 16 ++++++++-------- app/models/LoanDetail.js | 4 ++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/controllers/loan.details.controller.js b/app/controllers/loan.details.controller.js index aeba8eb..6a29a58 100644 --- a/app/controllers/loan.details.controller.js +++ b/app/controllers/loan.details.controller.js @@ -16,9 +16,9 @@ exports.mainLandingPage = async (req, res) => if(req.query.is_loan_api_call == 0) { LoanDetail.findAll({raw: true ,where:{ losid:req.query.losid , is_active : 1}, - include: [{ model: ApplicantsDetails , // Set the alias for the relationship + include: [{ model: EntityDetails , // Set the alias for the relationship attributes: [ - [sequelize.col('name'), 'loan_applicant_name'] // Alias for the 'name' column + [sequelize.col('entity_name'), 'loan_applicant_name'] // Alias for the 'name' column ] }] }).then(data => { if(data.length > 0) @@ -60,9 +60,9 @@ exports.mainLandingPage = async (req, res) => ModuleWiseStatusHelper.moduleCompletionStatusDataCreationHelper(loanDetailData.loginNo); // Final Response LoanDetail.findAll({raw: true ,where:{ losid:req.query.losid , is_active : 1}, - include: [{ model: ApplicantsDetails , // Set the alias for the relationship + include: [{ model: EntityDetails , // Set the alias for the relationship attributes: [ - [sequelize.col('name'), 'loan_applicant_name'] // Alias for the 'name' column + [sequelize.col('entity_name'), 'loan_applicant_name'] // Alias for the 'name' column ] }] }).then(data => { if(data.length > 0) { res.send({'status':200,'message':"success",'data':data}); } else { res.send({'status':404,'message':"failed",'data':"No data"}); } }) // Entity detail promise @@ -179,9 +179,9 @@ exports.mainLandingPage = async (req, res) => { logMsg.info("Los api call Failed " +req.query.losid); LoanDetail.findAll({raw: true ,where:{ losid:req.query.losid , is_active : 1}, - include: [{ model: ApplicantsDetails , // Set the alias for the relationship + include: [{ model: EntityDetails , // Set the alias for the relationship attributes: [ - [sequelize.col('name'), 'loan_applicant_name'] // Alias for the 'name' column + [sequelize.col('entity_name'), 'loan_applicant_name'] // Alias for the 'name' column ] }] }).then(data => { if(data.length > 0) @@ -203,9 +203,9 @@ exports.mainLandingPage = async (req, res) => logMsg.info("Data already inserted " +req.query.losid); // Final Response LoanDetail.findAll({raw: true ,where:{ losid:req.query.losid , is_active : 1}, - include: [{ model: ApplicantsDetails , // Set the alias for the relationship + include: [{ model: EntityDetails , // Set the alias for the relationship attributes: [ - [sequelize.col('name'), 'loan_applicant_name'] // Alias for the 'name' column + [sequelize.col('entity_name'), 'loan_applicant_name'] // Alias for the 'name' column ] }] }).then(data => { if(data.length > 0) diff --git a/app/models/LoanDetail.js b/app/models/LoanDetail.js index 230cb9f..d504df3 100644 --- a/app/models/LoanDetail.js +++ b/app/models/LoanDetail.js @@ -44,6 +44,10 @@ module.exports = (sequelize, DataTypes) => { foreignKey: 'loan_no_id', sourceKey : 'id' }); + LoanDetail.hasMany(models.EntityDetails, { + foreignKey: 'loan_no_id', + sourceKey : 'id' + }); } return LoanDetail } \ No newline at end of file