GWM
This commit is contained in:
parent
2ae702b0ee
commit
604a9122d0
83
app/controllers/loan.details.controller.js
Normal file
83
app/controllers/loan.details.controller.js
Normal file
@ -0,0 +1,83 @@
|
||||
const { sequelize , LoanDetail , EntityDetails , ApplicantsDetails , ApplicantsRelationship , ResidenceAddressDetails , PropertyOwnershipIncomeConsidered , DueDiligenceCheck , TradeReferences , CheckTypeMaster , EnquiriesAndDisbursements , PropertyAndLtv , ATNWrelatedInputs , SalesPD , ATNWrelatedInputMaster ,ATNWrelationship , OtherParameterMaster ,OtherParameterMasterValue , OtherParameterRelationship , OtherParameters , ATNErelatedInputSubVal , DataFromLos , FormulaMaster , LoanAndLtvMaster , EntityApplicantMaster } = require('../models')
|
||||
const { logMsg } = require('../services/logger.js');
|
||||
const ApiCallHelper = require('../services/ApiCallHelper.js');
|
||||
const moment = require('moment');
|
||||
|
||||
|
||||
|
||||
|
||||
//LoanDeatilList List Api
|
||||
exports.LoanDeatilListTEST = async (req, res) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
data = await ApiCallHelper.loanDetailsDataApiCall('MW00004618','AXZPP6264B');
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
// if (data.status == 'Successful')
|
||||
// {
|
||||
// if (data.lstLoanApplication.length != 0)
|
||||
// {
|
||||
// loanDetailData = data.lstLoanApplication[0];
|
||||
// loanDetailObject = {
|
||||
// applicationNo : loanDetailData.applicationNo,
|
||||
// losid : loanDetailData.loginNo ,
|
||||
// date_of_login : moment(new Date(loanDetailData.loginDate)).format("YYYY-MM-DD"),
|
||||
// sourcing_channel_name : loanDetailData.source,
|
||||
// emi_of_loan_applied_for : LoanDeatilList.loanAmount,
|
||||
// //product : LoanDeatilList.iD_LoanProduct
|
||||
// }
|
||||
// LoanDetail.create(loanDetailObject).then(LoanDetailData =>
|
||||
// {
|
||||
// if (data.lstApplicantKYCDetail.length != 0)
|
||||
// {
|
||||
// var ApplicantKYCDetailDataInsert = new Promise(async(resolve, reject) => {
|
||||
// lstApplicantKYCDetailDataArray = [];
|
||||
// data.lstApplicantKYCDetail.forEach(async(value,index,array) => {
|
||||
|
||||
// lstApplicantKYCDetailObj = {
|
||||
|
||||
|
||||
// }
|
||||
// lstApplicantKYCDetailDataArray.push(lstApplicantKYCDetailObj);
|
||||
|
||||
// if (index === array.length -1) { resolve(lstApplicantKYCDetailDataArray); }
|
||||
// });
|
||||
// });
|
||||
// ApplicantKYCDetailDataInsert.then(async(lstApplicantKYCDetailDataArray)=>{
|
||||
// console.log(lstApplicantKYCDetailDataArray);
|
||||
// await ApplicantsDetails.bulkCreate(lstApplicantKYCDetailDataArray).catch(err=>{ });
|
||||
// });
|
||||
|
||||
// } else { } // lstApplicantKYCDetail array is empty from Los api
|
||||
|
||||
// }).catch(err => {res.send({'status':404,message: err.message || "Some error occurred while retrieving statements." ,'data': "No data" });});
|
||||
|
||||
|
||||
// } else { } // lstLoanApplication array is empty from Los api
|
||||
|
||||
// } else { } // Los api call failed
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// LoanDetail.findAll({raw: true , where : { losid : req.query.losid , 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
|
||||
|
||||
};
|
||||
@ -7,7 +7,7 @@ module.exports = (sequelize, DataTypes) => {
|
||||
LoanDetail.init(
|
||||
{
|
||||
losid: { type: DataTypes.STRING },
|
||||
// loan_no: { type: DataTypes.INTEGER },
|
||||
// applicationNo: { type: DataTypes.INTEGER },
|
||||
product : { type: DataTypes.STRING },
|
||||
date_of_login: { type: DataTypes.INTEGER },
|
||||
sourcing_channel_type: { type: DataTypes.INTEGER },
|
||||
|
||||
@ -4,9 +4,11 @@ module.exports = app => {
|
||||
const Testcontroller = require("../controllers/test.controller.js");
|
||||
const Entitycontroller = require("../controllers/entity.applicant.controller.js");
|
||||
const Mastercontroller = require("../controllers/master.controller.js");
|
||||
const Loancontroller = require("../controllers/loan.details.controller.js");
|
||||
const { logMsg } = require('../services/logger.js');
|
||||
var router = require("express").Router();
|
||||
|
||||
router.get("/LoanDeatilListTEST", Loancontroller.LoanDeatilListTEST);
|
||||
// demo welcome Api
|
||||
/**
|
||||
* @swagger
|
||||
@ -21,7 +23,28 @@ module.exports = app => {
|
||||
router.get("/demo", Testcontroller.Welcome);
|
||||
|
||||
|
||||
// router.get("/copy", Testcontroller.copy);
|
||||
// LoanDeatilList List Api
|
||||
/**
|
||||
* @swagger
|
||||
* /api/LoanDeatilList:
|
||||
* get:
|
||||
* summary: Loan Numbers Details List
|
||||
* description: Get loan Number Details List
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: losid
|
||||
* schema:
|
||||
* type: string
|
||||
* required: true
|
||||
* description: id of the loan detail Details (primart key of entity)
|
||||
* example: MW112233
|
||||
* responses:
|
||||
* 200:
|
||||
* description: success
|
||||
*/
|
||||
router.get("/LoanDeatilList", Entitycontroller.LoanDeatilList);
|
||||
|
||||
|
||||
|
||||
// entity_applicant_name list for banking module
|
||||
/**
|
||||
@ -2344,29 +2367,6 @@ router.get("/otherParametersList", Entitycontroller.OtherParametersList);
|
||||
router.post("/updateLoanDetail", Entitycontroller.updateLoanDetail);
|
||||
|
||||
|
||||
// LoanDeatilList List Api
|
||||
/**
|
||||
* @swagger
|
||||
* /api/LoanDeatilList:
|
||||
* get:
|
||||
* summary: Loan Numbers Details List
|
||||
* description: Get loan Number Details List
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: losid
|
||||
* schema:
|
||||
* type: string
|
||||
* required: true
|
||||
* description: id of the loan detail Details (primart key of entity)
|
||||
* example: MW112233
|
||||
* responses:
|
||||
* 200:
|
||||
* description: success
|
||||
*/
|
||||
router.get("/LoanDeatilList", Entitycontroller.LoanDeatilList);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Pan List Api For Cibil
|
||||
|
||||
75
app/services/ApiCallHelper.js
Normal file
75
app/services/ApiCallHelper.js
Normal file
@ -0,0 +1,75 @@
|
||||
//const { sequelize} = require('../models');
|
||||
const { logMsg } = require('../services/logger.js');
|
||||
const request = require('request');
|
||||
|
||||
|
||||
|
||||
async function loanDetailsDataApiCall(losid,pan_no) {
|
||||
try {
|
||||
LOAN_URL = process.env.LOS_DATA_URL;
|
||||
token = await getLoginToken();
|
||||
request_object = {
|
||||
"losid": losid,
|
||||
"panNo": pan_no
|
||||
};
|
||||
return new Promise((resolve, reject) => {
|
||||
request({
|
||||
url: LOAN_URL,
|
||||
method: "POST",
|
||||
headers: { Authorization: 'Bearer ' + token },
|
||||
json: true,
|
||||
body: request_object
|
||||
}, function (error, response, body){
|
||||
// let data = JSON.parse(response); console.log(response);
|
||||
// if(data.status == 'Successful')
|
||||
// {
|
||||
// resolve(data);
|
||||
// }
|
||||
resolve(body);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function getLoginToken() {
|
||||
try {
|
||||
|
||||
const url = process.env.TOKEN_URL;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
request({
|
||||
url: url,
|
||||
method: "GET"
|
||||
}, function (error, response, body){
|
||||
data = JSON.parse(body);
|
||||
if(data.status === 200)
|
||||
{
|
||||
resolve(data.data.token);
|
||||
}
|
||||
else { resolve(false); }
|
||||
|
||||
})
|
||||
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
module.exports = {
|
||||
|
||||
loanDetailsDataApiCall : loanDetailsDataApiCall,
|
||||
getLoginToken : getLoginToken
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user