From 6c97e9f375173a87b666d484738d49b742cdd6d4 Mon Sep 17 00:00:00 2001 From: sriramv Date: Sat, 30 Apr 2022 14:28:55 +0530 Subject: [PATCH] gwm --- app/controllers/salespd.controller.js | 42 ++++++++++++++++++--------- app/routes/routes.js | 12 ++------ app/services/apicallhelper.js | 32 ++++++++++++++++++++ 3 files changed, 63 insertions(+), 23 deletions(-) create mode 100644 app/services/apicallhelper.js diff --git a/app/controllers/salespd.controller.js b/app/controllers/salespd.controller.js index 854f8b4..f04b0ee 100644 --- a/app/controllers/salespd.controller.js +++ b/app/controllers/salespd.controller.js @@ -1,28 +1,42 @@ const { sequelize, GeneralSection , BreifOfBusiness , DetailsOfKeyShareHolder , FinalRemarks , FinancialInformation , FundRequirement , InstitutionDetail , OfficerDetails , Photograph , ProductInformation , PropertyInformation} = require('../models') const { logMsg } = require('../services/logger.js'); +const ApiCallHelper = require('../services/apicallhelper.js'); //GeneralSection data List Api -exports.GeneralSectionList = async (req, res) => +exports.SectionList = async (req, res) => { try { - GeneralSection.findAll({raw: true , where:{losid:req.query.losid,main_loan_applicant:req.query.main_loan_applicant,is_active : 1}}).then(data => + applicantDetails = await ApiCallHelper.MainApplicantDetails(req.query.losid); + MainApplicantDetails = JSON.parse(applicantDetails); + + if(MainApplicantDetails.status == 200) { - if(data.length > 0) - { - res.send({'status':200,'message':"success",'data':data}); - } - else { - res.send({'status':404,'message':"failed",'data':"No data"}); + GeneralSection.findAll({ where:{losid:req.query.losid,main_loan_applicant:MainApplicantDetails.data.name,is_active : 1}, + include: [ {model: FundRequirement }, {model: DetailsOfKeyShareHolder }, {model: DetailsOfKeyShareHolder }, {model: BreifOfBusiness }, {model: FinancialInformation }, {model: PropertyInformation }, {model: FinalRemarks }, {model: OfficerDetails }, {model: Photograph }, {model: InstitutionDetail }, {model: ProductInformation }] }) + .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 data" ,'data': "No data" }); - }); + + }) + .catch(err => { + res.send({'status':404,message: err.message || "Some error occurred while retrieving data" ,'data': "No 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 data." ,'data': "No data" }); diff --git a/app/routes/routes.js b/app/routes/routes.js index fa9e0a8..fc66311 100644 --- a/app/routes/routes.js +++ b/app/routes/routes.js @@ -31,9 +31,9 @@ module.exports = app => { //GeneralSection List Api /** * @swagger -* /api/GeneralSectionList: +* /api/SectionList: * get: -* summary: General Section Data List +* summary: General Section Data List with app child section data's * description: Get General Section Data List * parameters: * - in: query @@ -42,17 +42,11 @@ module.exports = app => { * type: string * required: true * example: MW112233 -* - in: query -* name: main_loan_applicant -* schema: -* type: string -* required: true -* example: AKSHAR ENTERPRISE * responses: * 200: * description: success */ -router.get("/GeneralSectionList", SalesPdController.GeneralSectionList); +router.get("/SectionList", SalesPdController.SectionList); //BreifOfBusiness List Api /** diff --git a/app/services/apicallhelper.js b/app/services/apicallhelper.js new file mode 100644 index 0000000..76966c5 --- /dev/null +++ b/app/services/apicallhelper.js @@ -0,0 +1,32 @@ +const request = require('request'); + + + +function MainApplicantDetails(losid) { + try { + const url = "https://demo.devopsmcfinance.com/cet_mainapp/api/MainApplicantDetailsList?losid="+losid; + + return new Promise((resolve, reject) => { + request({ + url: url, + method: "GET" + + }, function (error, response, body) { + resolve(body); + }); + + }); + } + catch (error) { + console.log(error); + } +} + + + + + +module.exports = { + MainApplicantDetails: MainApplicantDetails + +} \ No newline at end of file