diff --git a/app/controllers/entity.applicant.controller.js b/app/controllers/entity.applicant.controller.js index b6bdfd8..155fae1 100644 --- a/app/controllers/entity.applicant.controller.js +++ b/app/controllers/entity.applicant.controller.js @@ -34,12 +34,10 @@ exports.createApplicantDetails = async (req, res) => delete req.body.applicant_relationship delete req.body.residence_address delete req.body.property_ownership_income_considered ; - await ApplicantsDetails.create(req.body).then(async (data) => { if(req.body.entity_type == "Individual") { - ApplicantsRelationshipData = Object.assign(ApplicantsRelationshipData, {applicant_id: data.dataValues.id}); await ApplicantsRelationship.create(ApplicantsRelationshipData) .then(data=>{logMsg.info("ApplicantsRelationship inserted");}).catch(err=>{logMsg.info("ApplicantsRelationship Failed , Msg :" +err);}); diff --git a/app/controllers/master.controller.js b/app/controllers/master.controller.js index 21cbaf2..742a613 100644 --- a/app/controllers/master.controller.js +++ b/app/controllers/master.controller.js @@ -1,6 +1,6 @@ const { sequelize,EntityApplicantMaster,StateMaster,CityMaster,PinMaster,ChecktypeCheckresultRelationMaster - ,DueDiligenceCheck,CheckResultMaster} = require('../models') - const { logMsg } = require('../services/logger.js'); + ,DueDiligenceCheck,CheckResultMaster,CheckTypeMaster} = require('../models') +const { logMsg } = require('../services/logger.js'); // select entityMaster data @@ -16,12 +16,12 @@ const { sequelize,EntityApplicantMaster,StateMaster,CityMaster,PinMaster,Checkty }) .catch(err => { res.send({'status':404, - message: err.message || "Some error occurred while retrieving statements." ,'data': "No data" }); + message: err.message || "Some error occurred while fetching entity applicant masterdata." ,'data': "No data" }); }); } catch(err) { res.send({'status':404, - message: err.message || "Some error occurred while inserting statements." ,'data': "No data" + message: err.message || "Some error occurred while fetching entity applicant masterdata." ,'data': "No data" }); } //end of try catch @@ -30,26 +30,23 @@ const { sequelize,EntityApplicantMaster,StateMaster,CityMaster,PinMaster,Checkty // create entity master data exports.CreateEntityApplicantMasterData = async (req, res) => { - try { await EntityApplicantMaster.create(req.body) .then(data => { - res.send({'status':200,'message':"success",'data':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" }); + message: err.message || "Some error occurred while create entity applicant masterdata." ,'data': "No data" }); }); } catch(err) { res.send({'status':404, - message: err.message || "Some error occurred while inserting statements." ,'data': "No data" + message: err.message || "Some error occurred while create entity applicant masterdata." ,'data': "No data" }); - } //end of try catch - + } //end of try catch }; @@ -58,7 +55,7 @@ const { sequelize,EntityApplicantMaster,StateMaster,CityMaster,PinMaster,Checkty { try { - await StateMaster.findAll() + await StateMaster.findAll({ where : {"is_active" : 1}}) .then(data => { res.send({'status':200,'message':"success",'data':data}); @@ -66,12 +63,12 @@ const { sequelize,EntityApplicantMaster,StateMaster,CityMaster,PinMaster,Checkty }) .catch(err => { res.send({'status':404, - message: err.message || "Some error occurred while retrieving statements." ,'data': "No data" }); + message: err.message || "Some error occurred while fetching state masterdata." ,'data': "No data" }); }); } catch(err) { res.send({'status':404, - message: err.message || "Some error occurred while inserting statements." ,'data': "No data" + message: err.message || "Some error occurred while fetching state masterdata." ,'data': "No data" }); } //end of try catch @@ -82,7 +79,7 @@ const { sequelize,EntityApplicantMaster,StateMaster,CityMaster,PinMaster,Checkty { try { - await CityMaster.findAll({ where : { "state_id" : req.query.state_id }}) + await CityMaster.findAll({ where : { "state_id" : req.query.state_id , "is_active" : 1 }}) .then(data => { res.send({'status':200,'message':"success",'data':data }); @@ -90,12 +87,12 @@ const { sequelize,EntityApplicantMaster,StateMaster,CityMaster,PinMaster,Checkty }) .catch(err => { res.send({'status':404, - message: err.message || "Some error occurred while retrieving statements." ,'data': "No data" }); + message: err.message || "Some error occurred while fetching city masterdata." ,'data': "No data" }); }); } catch(err) { res.send({'status':404, - message: err.message || "Some error occurred while inserting statements." ,'data': "No data" + message: err.message || "Some error occurred while fetching city masterdata." ,'data': "No data" }); } //end of try catch @@ -106,7 +103,7 @@ const { sequelize,EntityApplicantMaster,StateMaster,CityMaster,PinMaster,Checkty { try { - await PinMaster.findAll({ where : { "state_id" : req.query.state_id }}) + await PinMaster.findAll({ where : { "state_id" : req.query.state_id , "is_active" : 1 }}) .then(data => { res.send({'status':200,'message':"success",'data':data}); @@ -114,31 +111,85 @@ const { sequelize,EntityApplicantMaster,StateMaster,CityMaster,PinMaster,Checkty }) .catch(err => { res.send({'status':404, - message: err.message || "Some error occurred while retrieving statements." ,'data': "No data" }); + message: err.message || "Some error occurred while fetching pin masterdata." ,'data': "No data" }); }); } catch(err) { res.send({'status':404, - message: err.message || "Some error occurred while inserting statements." ,'data': "No data" + message: err.message || "Some error occurred while fetching pin masterdata." ,'data': "No data" }); } //end of try catch }; + // select checkResultMaster exports.CheckResultMaster = async (req, res) => { 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 JOIN check_result_master ON checktype_checkresult_relation_master.check_result_id = check_result_master.id') - res.send({'status':200,'message':"success",'data':storeData}); + 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 + + }) + .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 inserting statements." ,'data': "No data" + message: err.message || "Some error occurred while fetching check result master data." ,'data': "No data" }); } //end of try catch }; + + // create check type master + exports.CreateCheckTypeMaster = async (req, res) => + { + try + { + await CheckTypeMaster.create(req.body) + .then(data => + { + res.send({'status':200,'message':"success",'data':"success"}); + + }) + .catch(err => { + res.send({'status':404, + message: err.message || "Some error occurred while create type masterdata." ,'data': "No data" }); + }); + + } catch(err) { + res.send({'status':404, + message: err.message || "Some error occurred while create type masterdata." ,'data': "No data" + }); + } //end of try catch + }; + + // create relation master + exports.CreateRelationMaster = async (req, res) => + { + try + { + await ChecktypeCheckresultRelationMaster.create(req.body) + .then(data => + { + res.send({'status':200,'message':"success",'data':"success"}); + + }) + .catch(err => { + res.send({'status':404, + message: err.message || "Some error occurred while create relation masterdata." ,'data': "No data" }); + }); + + } catch(err) { + res.send({'status':404, + message: err.message || "Some error occurred while create relation masterdata." ,'data': "No data" + }); + } //end of try catch + }; \ No newline at end of file diff --git a/app/models/CheckResultMaster.js b/app/models/CheckResultMaster.js index c366316..e3963a3 100644 --- a/app/models/CheckResultMaster.js +++ b/app/models/CheckResultMaster.js @@ -6,7 +6,8 @@ module.exports = (sequelize, DataTypes) => { } CheckResultMaster.init( { - value: { type: DataTypes.STRING } + value: { type: DataTypes.STRING }, + is_active: { type: DataTypes.INTEGER } }, { sequelize, diff --git a/app/models/CheckTypeMaster.js b/app/models/CheckTypeMaster.js new file mode 100644 index 0000000..18962dc --- /dev/null +++ b/app/models/CheckTypeMaster.js @@ -0,0 +1,23 @@ +'use strict' +const { Model } = require('sequelize') +module.exports = (sequelize, DataTypes) => { + class CheckTypeMaster extends Model { + + } + CheckTypeMaster.init( + { + value: { type: DataTypes.STRING }, + is_active: { type: DataTypes.INTEGER } + }, + { + sequelize, + tableName: 'check_type_master', + modelName: 'CheckTypeMaster', + } + ) + + + + + return CheckTypeMaster +} \ No newline at end of file diff --git a/app/models/ChecktypeCheckresultRelationMaster.js b/app/models/ChecktypeCheckresultRelationMaster.js index 64cd05a..677c9bd 100644 --- a/app/models/ChecktypeCheckresultRelationMaster.js +++ b/app/models/ChecktypeCheckresultRelationMaster.js @@ -8,7 +8,8 @@ module.exports = (sequelize, DataTypes) => { ChecktypeCheckresultRelationMaster.init( { check_type_id: { type: DataTypes.INTEGER }, - check_result_id: { type: DataTypes.INTEGER } + check_result_id: { type: DataTypes.INTEGER }, + is_active: { type: DataTypes.INTEGER } }, { sequelize, diff --git a/app/models/CityMaster.js b/app/models/CityMaster.js index 257cdfc..624e3c7 100644 --- a/app/models/CityMaster.js +++ b/app/models/CityMaster.js @@ -7,7 +7,8 @@ module.exports = (sequelize, DataTypes) => { CityMaster.init( { state_id: { type: DataTypes.INTEGER }, - city: { type: DataTypes.STRING } + city: { type: DataTypes.STRING }, + is_active: { type: DataTypes.INTEGER } }, { diff --git a/app/models/PinMaster.js b/app/models/PinMaster.js index f2afb29..6dfc4a3 100644 --- a/app/models/PinMaster.js +++ b/app/models/PinMaster.js @@ -7,7 +7,8 @@ module.exports = (sequelize, DataTypes) => { PinMaster.init( { state_id: { type: DataTypes.STRING }, - pin: { type: DataTypes.INTEGER } + pin: { type: DataTypes.INTEGER }, + is_active: { type: DataTypes.INTEGER } }, { diff --git a/app/models/StateMaster.js b/app/models/StateMaster.js index 07dcdf4..198d314 100644 --- a/app/models/StateMaster.js +++ b/app/models/StateMaster.js @@ -6,7 +6,8 @@ module.exports = (sequelize, DataTypes) => { } StateMaster.init( { - state: { type: DataTypes.STRING } + state: { type: DataTypes.STRING }, + is_active: { type: DataTypes.INTEGER } }, { diff --git a/app/routes/routes.js b/app/routes/routes.js index c15a688..13e3afa 100644 --- a/app/routes/routes.js +++ b/app/routes/routes.js @@ -1,3 +1,5 @@ +const CheckTypeMaster = require("../models/CheckTypeMaster.js"); + module.exports = app => { const request = require("request"); const cors=require('cors'); @@ -172,7 +174,12 @@ router.get("/propertyOwnershipList", Entitycontroller.PropertyOwnershipList); */ router.post("/createEntityDetails", Entitycontroller.createEntityDetails); + + + // Create new Applicant and it's child Details (Relationship, Address, Property ownership) // + + router.post("/createApplicantDetails", Entitycontroller.createApplicantDetails); @@ -180,20 +187,22 @@ router.post("/createApplicantDetails", Entitycontroller.createApplicantDetails); + + // Master data Api's // EntityApplicantMaster data select api /** * @swagger -* /api/dropdownMasterData: +* /api/entityApplicantMasterData: * get: -* summary: Dropdown master data Api -* description: All master data for dropdown value +* summary: Dropdown data Api +* description: Dropdown data for entity and applicant master data Api * responses: * 200: * description: success */ -router.get("/entityApplicantMasterData", Mastercontroller.EntityApplicantMasterData); //line 7 +router.get("/entityApplicantMasterData", Mastercontroller.EntityApplicantMasterData); @@ -238,7 +247,7 @@ router.get("/entityApplicantMasterData", Mastercontroller.EntityApplicantMasterD * 500: * description: failure in inserting entity applicant details */ -router.post("/createEntityApplicantMasterData", Mastercontroller.CreateEntityApplicantMasterData); // line 31 +router.post("/createEntityApplicantMasterData", Mastercontroller.CreateEntityApplicantMasterData); @@ -249,12 +258,15 @@ router.post("/createEntityApplicantMasterData", Mastercontroller.CreateEntityApp * /api/stateMasterData: * get: * summary: Dropdown state master data Api +* operationId: readappmaster +* tags: +* - createEntityApplicantMasterData * description: All master data for dropdown value * responses: * 200: * description: success */ -router.get("/stateMasterData", Mastercontroller.StateMasterData); // line 82 +router.get("/stateMasterData", Mastercontroller.StateMasterData); @@ -278,7 +290,7 @@ router.get("/stateMasterData", Mastercontroller.StateMasterData); // line 82 * 200: * description: success */ -router.get("/cityMasterData", Mastercontroller.CityMasterData); // line 106 +router.get("/cityMasterData", Mastercontroller.CityMasterData); @@ -303,7 +315,7 @@ router.get("/cityMasterData", Mastercontroller.CityMasterData); // line 106 * 200: * description: success */ -router.get("/pinMasterData", Mastercontroller.PinMasterData); // line 130 +router.get("/pinMasterData", Mastercontroller.PinMasterData); @@ -314,8 +326,8 @@ router.get("/pinMasterData", Mastercontroller.PinMasterData); // line 130 * @swagger * /api/checkResultMasterData: * get: -* summary: Due Diligence Check master data Api -* description: Due Diligence Check master data for dropdown value +* summary: Check result master data Api +* description: Check result master data for dropdown value * responses: * 200: * description: success @@ -323,9 +335,83 @@ router.get("/pinMasterData", Mastercontroller.PinMasterData); // line 130 router.get("/checkResultMasterData", Mastercontroller.CheckResultMaster); +// create check type master + +/** +* @swagger +* definitions: +* CreateCheckTypeMaster: +* type: object +* properties: +* value: +* type: string +* description: value +* example: abcd +* is_active: +* type: integer +* description: is_active +* example: 1 +*/ +/** +* @swagger +* /api/CreateCheckTypeMaster: +* post: +* summary: create check type master data +* description: create a new check type master data +* requestBody: +* content: +* application/json: +* schema: +* $ref: '#/definitions/CreateCheckTypeMaster' +* responses: +* 200: +* description: New check type master data details inserted +* 500: +* description: failure in inserting check type master data details +*/ +router.post('/CreateCheckTypeMaster',Mastercontroller.CreateCheckTypeMaster) +// create relation master data + +/** +* @swagger +* definitions: +* CreateRelationMaster: +* type: object +* properties: +* check_type_id: +* type: integer +* description: checktypeid +* example: 1 +* check_result_id: +* type: integer +* description: check_result_id +* example: 1 +* is_active: +* type: integer +* description: is_active +* example: 1 +*/ +/** +* @swagger +* /api/CreateRelationMaster: +* post: +* summary: create CreateRelationMaster data +* description: create a new CreateRelationMaster data +* requestBody: +* content: +* application/json: +* schema: +* $ref: '#/definitions/CreateRelationMaster' +* responses: +* 200: +* description: New CreateRelationMaster data details inserted +* 500: +* description: failure in inserting CreateRelationMaster data details +*/ +router.post('/CreateRelationMaster',Mastercontroller.CreateRelationMaster)