diff --git a/app/controllers/credit.policy.controller.js b/app/controllers/credit.policy.controller.js index cc77f9f..2b1b470 100644 --- a/app/controllers/credit.policy.controller.js +++ b/app/controllers/credit.policy.controller.js @@ -3,6 +3,32 @@ const { logMsg } = require('../services/logger.js'); const policyHelper = require('../services/policy.helper'); + + + exports.MasterDataList = async (req, res) => + { + try + { + + ProgramMasterData = await ProgramMaster.findAll({attributes:['id','program_name'],where:{is_active:1}}); + CheckTypeMasterData = await CheckTypeMaster.findAll({attributes:['id','check_type'],where:{is_active:1}}); + PropertyTypeMasterData = await PropertyTypeMaster.findAll({attributes:['id','property_type'],where:{is_active:1}}); + BusinessActivityMasterData = await BusinessActivityMaster.findAll({attributes:['id','business_activity_name'],where:{is_active:1}}); + const resData = {ProgramMaster:ProgramMasterData,CheckTypeMaster:CheckTypeMasterData,PropertyTypeMaster:PropertyTypeMasterData,BusinessActivityMaster:BusinessActivityMasterData}; + + res.send({'status':200,'message':"success",'data':resData}); + + } catch(err) { + res.send({'status':404, + message: err.message || "Some error occurred while fetching entity applicant masterdata." ,'data': "No data" + }); + } //end of try catch + + }; + + + + // select PolicyParameterMaster data exports.ParameterMasterData = async (req, res) => { @@ -52,7 +78,33 @@ exports.ParameterMasterData = async (req, res) => }; - + exports.updateDoubleWhammy = async (req, res) => + { + try + { + // Multiple update + DoubleWhammyData = req.body; + for(const DoubleWhammyDataValue of DoubleWhammyData) + { + id = DoubleWhammyDataValue.id; + delete DoubleWhammyDataValue.id; + await DoubleWhammy.update(DoubleWhammyDataValue,{ where: { id: id }}) + .then(async(data) =>{ + logMsg.info("Update Success DoubleWhammy , id = "+id); + + }).catch(err=>{ logMsg.info("Update Failed DoubleWhammy , id = "+id); }); + + } + setTimeout(() => { + res.send({'status':200,'message':"success",'data':"No data"}); + }, 1500); + + } catch(err) { + res.send({'status':404,message: err.message || "Some error occurred while updating BankCredits." ,'data': "No data" }); + } //end of try catch + + }; + exports.DscrLeverageGridDataList = async (req, res) => @@ -78,7 +130,32 @@ exports.ParameterMasterData = async (req, res) => }; - + exports.updateDscrLeverageGrid = async (req, res) => + { + try + { + // Multiple update + DscrLeverageGridData = req.body; + for(const DscrLeverageGridDataValue of DscrLeverageGridData) + { + id = DscrLeverageGridDataValue.id; + delete DscrLeverageGridDataValue.id; + await DscrLeverageGrid.update(DscrLeverageGridDataValue,{ where: { id: id }}) + .then(async(data) =>{ + logMsg.info("Update Success DoubleWhammy , id = "+id); + + }).catch(err=>{ logMsg.info("Update Failed DoubleWhammy , id = "+id); }); + + } + setTimeout(() => { + res.send({'status':200,'message':"success",'data':"No data"}); + }, 1500); + + } catch(err) { + res.send({'status':404,message: err.message || "Some error occurred while updating BankCredits." ,'data': "No data" }); + } //end of try catch + + }; exports.LeverageUsedForEligCatDataList = async (req, res) => { @@ -104,6 +181,34 @@ exports.ParameterMasterData = async (req, res) => }; + exports.updateLeverageUsedForEligCat = async (req, res) => + { + try + { + // Multiple update + LeverageUsedForEligCatData = req.body; + for(const LeverageUsedForEligCatValue of LeverageUsedForEligCatData) + { + id = LeverageUsedForEligCatValue.id; + delete LeverageUsedForEligCatValue.id; + await LeverageUsedForEligCat.update(LeverageUsedForEligCatValue,{ where: { id: id }}) + .then(async(data) =>{ + logMsg.info("Update Success DoubleWhammy , id = "+id); + + }).catch(err=>{ logMsg.info("Update Failed DoubleWhammy , id = "+id); }); + + } + setTimeout(() => { + res.send({'status':200,'message':"success",'data':"No data"}); + }, 1500); + + } catch(err) { + res.send({'status':404,message: err.message || "Some error occurred while updating BankCredits." ,'data': "No data" }); + } //end of try catch + + }; + + // select AdjustableTang data @@ -132,7 +237,32 @@ exports.AdjustableTang = async (req, res) => - +exports.updateAdjustableTang = async (req, res) => +{ + try + { + // Multiple update + AdjustableTangDataArray = req.body; + for(const AdjustableTangValue of AdjustableTangDataArray) + { + id = AdjustableTangValue.id; + delete AdjustableTangValue.id; + await AdjustableTang.update(AdjustableTangValue,{ where: { id: id }}) + .then(async(data) =>{ + logMsg.info("Update Success DoubleWhammy , id = "+id); + + }).catch(err=>{ logMsg.info("Update Failed DoubleWhammy , id = "+id); }); + + } + setTimeout(() => { + res.send({'status':200,'message':"success",'data':"No data"}); + }, 1500); + + } catch(err) { + res.send({'status':404,message: err.message || "Some error occurred while updating BankCredits." ,'data': "No data" }); + } //end of try catch + +}; diff --git a/app/routes/routes.js b/app/routes/routes.js index 8eab34b..9d51d48 100644 --- a/app/routes/routes.js +++ b/app/routes/routes.js @@ -9,18 +9,18 @@ module.exports = app => { - +//Master Data select api /** * @swagger -* /api/demo: +* /api/MasterDataList: * get: -* summary: Demo Api -* description: Welcome Message +* summary: MasterData Api +* description: MasterData Api * responses: * 200: * description: success */ - router.get("/demo", Mycontroller.Welcome); +router.get("/MasterDataList", CreditPolicy.MasterDataList); // Parameter Master Data select api @@ -91,7 +91,301 @@ router.get("/LeverageUsedForEligCatDataList", CreditPolicy.LeverageUsedForEligCa router.get("/AdjustableTang", CreditPolicy.AdjustableTang); - // TokenApi + +/** +* @swagger +* definitions: +* updateDoubleWhammy: +* type: array +* items: +* type: object +* properties: +* id: +* type: integer +* description: +* example: 50 +* program_id: +* type: integer +* description: +* example: 1 +* check_type_id: +* type: integer +* description: +* example: 1 +* property_type_id: +* type: integer +* description: +* example: 1 +* property_usage: +* type: string +* description: +* example: Self Occupied +* eligibility_factor_1: +* type: string +* description: +* example: 125 +* eligibility_factor_2: +* type: string +* description: +* example: 133 +* eligibility_factor_3: +* type: string +* description: +* example: 143 +* eligibility_factor_4: +* type: string +* description: +* example: 154 +* eligibility_factor_5: +* type: string +* description: +* example: 167 +* result: +* type: string +* description: +* example: Applicable +* is_active: +* type: integer +* description: +* example: 1 +* updatedby: +* type: integer +* description: +* example: 1 +*/ +/** +* @swagger +* /api/updateDoubleWhammy: +* post: +* summary: +* description: +* requestBody: +* content: +* application/json: +* schema: +* $ref: '#/definitions/updateDoubleWhammy' +* responses: +* 200: +* description: update success +* 500: +* description: failure in update +*/ +router.post("/updateDoubleWhammy", CreditPolicy.updateDoubleWhammy); + + +/** +* @swagger +* definitions: +* updateDscrLeverageGrid: +* type: array +* items: +* type: object +* properties: +* id: +* type: integer +* description: +* example: 1 +* program_id: +* type: integer +* description: +* example: 1 +* business_activity_id: +* type: integer +* description: +* example: 1 +* leverage: +* type: string +* description: +* example: "<=3" +* dscr_min: +* type: string +* description: +* example: ">=0.95" +* dscr_max: +* type: string +* description: +* example: null +* result: +* type: string +* description: +* example: No Deviation +* is_active: +* type: integer +* description: +* example: 1 +* updatedby: +* type: integer +* description: +* example: 1 +*/ +/** +* @swagger +* /api/updateDscrLeverageGrid: +* post: +* summary: +* description: +* requestBody: +* content: +* application/json: +* schema: +* $ref: '#/definitions/updateDscrLeverageGrid' +* responses: +* 200: +* description: update success +* 500: +* description: failure in update +*/ +router.post("/updateDscrLeverageGrid", CreditPolicy.updateDscrLeverageGrid); + + +/** +* @swagger +* definitions: +* updateLeverageUsedForEligCat: +* type: array +* items: +* type: object +* properties: +* id: +* type: integer +* description: +* example: 1 +* program_id: +* type: integer +* description: +* example: 1 +* business_activity_id: +* type: integer +* description: +* example: 1 +* leverage_value: +* type: integer +* description: +* example: 8 +* is_active: +* type: integer +* description: +* example: 1 +* updatedby: +* type: integer +* description: +* example: 1 +*/ +/** +* @swagger +* /api/updateLeverageUsedForEligCat: +* post: +* summary: +* description: +* requestBody: +* content: +* application/json: +* schema: +* $ref: '#/definitions/updateLeverageUsedForEligCat' +* responses: +* 200: +* description: update success +* 500: +* description: failure in update +*/ +router.post("/updateLeverageUsedForEligCat", CreditPolicy.updateLeverageUsedForEligCat); + + +/** +* @swagger +* definitions: +* updateAdjustableTang: +* type: array +* items: +* type: object +* properties: +* id: +* type: integer +* description: +* example: 806 +* property_ownership_document_available: +* type: string +* description: +* example: "Yes" +* type_of_property: +* type: string +* description: +* example: "Residential" +* property_used_in_business: +* type: string +* description: +* example: "Yes" +* property_free_loan_taken: +* type: string +* description: +* example: "No Loan on Property - Property Not on BS" +* property_in_the_name_of_applicant: +* type: string +* description: +* example: "Yes" +* loan_obligated_in_cet: +* type: string +* description: +* example: "Yes" +* property_created_in_last_eight_yr: +* type: string +* description: +* example: "Yes" +* value_to_be_considered: +* type: string +* description: +* example: "market_valuation_rs" +* mv_to_be_added_to_atnw: +* type: integer +* description: +* example: 100 +* final_value_considered: +* type: string +* description: +* example: "(value_to_be_considered * mv_to_be_added_to_atnw )" +* is_active: +* type: integer +* description: +* example: 1 +* updatedby: +* type: integer +* description: +* example: 1 +*/ +/** +* @swagger +* /api/updateAdjustableTang: +* post: +* summary: +* description: +* requestBody: +* content: +* application/json: +* schema: +* $ref: '#/definitions/updateAdjustableTang' +* responses: +* 200: +* description: update success +* 500: +* description: failure in update +*/ +router.post("/updateAdjustableTang", CreditPolicy.updateAdjustableTang); + + + + + + + + + + + + + + + +// TokenApi /** * @swagger