susee
This commit is contained in:
parent
a7c9f259a5
commit
23c490e485
53
.gitignore
vendored
53
.gitignore
vendored
@ -1,50 +1,3 @@
|
|||||||
# These are some examples of commonly ignored file patterns.
|
/node_modules
|
||||||
# You should customize this list as applicable to your project.
|
/storage
|
||||||
# Learn more about .gitignore:
|
.env
|
||||||
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore
|
|
||||||
|
|
||||||
# Node artifact files
|
|
||||||
node_modules/
|
|
||||||
dist/
|
|
||||||
|
|
||||||
# Compiled Java class files
|
|
||||||
*.class
|
|
||||||
|
|
||||||
# Compiled Python bytecode
|
|
||||||
*.py[cod]
|
|
||||||
|
|
||||||
# Log files
|
|
||||||
*.log
|
|
||||||
|
|
||||||
# Package files
|
|
||||||
*.jar
|
|
||||||
|
|
||||||
# Maven
|
|
||||||
target/
|
|
||||||
dist/
|
|
||||||
|
|
||||||
# JetBrains IDE
|
|
||||||
.idea/
|
|
||||||
|
|
||||||
# Unit test reports
|
|
||||||
TEST*.xml
|
|
||||||
|
|
||||||
# Generated by MacOS
|
|
||||||
.DS_Store
|
|
||||||
|
|
||||||
# Generated by Windows
|
|
||||||
Thumbs.db
|
|
||||||
|
|
||||||
# Applications
|
|
||||||
*.app
|
|
||||||
*.exe
|
|
||||||
*.war
|
|
||||||
|
|
||||||
# Large media files
|
|
||||||
*.mp4
|
|
||||||
*.tiff
|
|
||||||
*.avi
|
|
||||||
*.flv
|
|
||||||
*.mov
|
|
||||||
*.wmv
|
|
||||||
|
|
||||||
16
app/config/db.config.js
Normal file
16
app/config/db.config.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
require('dotenv').config();
|
||||||
|
|
||||||
|
const { logMsg } = require('../services/logger');
|
||||||
|
module.exports = {
|
||||||
|
|
||||||
|
"development": {
|
||||||
|
"username": process.env.USER_NAME,
|
||||||
|
"password": process.env.PASSWORD,
|
||||||
|
"database": process.env.DATABASE,
|
||||||
|
"port": process.env.PORT,
|
||||||
|
"host": process.env.HOST,
|
||||||
|
"dialect": "mssql",
|
||||||
|
"logging": (message) =>(logMsg.info(message))
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
72
app/controllers/test.controller.js
Normal file
72
app/controllers/test.controller.js
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
const { sequelize,Test,GeneralSection ,FundRequirement , DetailsOfKeyShareHolder , BreifOfBusiness , FinancialInformation , PropertyInformationn , FinalRemarks , OfficerDetails , Photograph , InstitutionDetail , ProductInformation} = require('../models')
|
||||||
|
const { logMsg } = require('../services/logger.js');
|
||||||
|
|
||||||
|
|
||||||
|
exports.Welcome = (req, res) =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const Msg = "Welcome....!";
|
||||||
|
console.log(Msg);
|
||||||
|
logMsg.info("Api Call Success");
|
||||||
|
res.send({'status':200 , message:"Success." ,'data': Msg});
|
||||||
|
|
||||||
|
} catch(err) {
|
||||||
|
res.status(500).send({'status':404,
|
||||||
|
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
|
||||||
|
}); } //end of try catch
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.SalesPd = async (req, res) =>
|
||||||
|
{
|
||||||
|
|
||||||
|
const tempData ={"section1":{"main_loan_applicant":"AKSHAR ENTERPRISE","company_name":"AKSHAR ENTERPRISE","person_met_during_visit":"SATWARA MANISH","address_visited":"SHED NO C 39 SURYAM INDUSTRIAL PARK NR TORRENT POWER SUBSTATION NICOL ","state":"Gujarat","city":"Ahmedabad","pincode":"382350"},"section2":{"loan_amount_applied":"25000000","total_fund_requirement":"30000000","loan_tenure":"36","loan_purpose":"Purchase of Business Assets"},"section3":[{"name":"SATHWARA MANISH","share_holding":"50","vintage_in_current_biz":"12"},{"name":"SATHWARA DHIRAJLAL HARDASBHAI","share_holding":"50","vintage_in_current_biz":"12"}],"section4":{"nature_of_business":"Trader","product_service_type":"LPG GAS TRADING","other_information":"RILIANCE LPG GAS"},"section5":{"0":{"fy":"2021-2022","sales_revenue":"59168882","net_profit":"2000000"},"income_considered":"2000000","income_assessment_program_recommended":"Vanilla","fixed_obligations":"1000000"},"section6":[{"property_address":"SHOP NO 601 TO 604 SUREEL BUSINESS HUB BS NARODA MUKTI DHAM SHALBI HOSPITAL ROAD NARODA","property_type":"SHOPS ","occupancy_status":"Vacant","permitted_property_usage":"Commercial","actual_property_usage":"Commercial","built_up_area":"6500","built_up_area_uom":"Sq Ft","approx_mkt_val":"40000000","Property_Ownership_Status":"PADMA ASSOCIATES "}],"section7":{"business_activity_seen":"Yes","location_workplace_suits_business":"Yes","overall_assessment":"Positive","recommended_roi":"13","any_other_remarks":""},"section8":{"name_of_sales_team_member":"Bhojak Krunalkumar Maheshkumar ","designation":"Sales Officer","date":"09-04-2022 2:01:16 PM"},"section9":{"selfie_with_person_met":"SAVED","approach_to_pd_location":["SAVED",""],"name_board_seen":["SAVED",""],"stock_image":["SAVED","SAVED","SAVED","SAVED",""],"workplace_interior_image":["SAVED","SAVED",""]}}
|
||||||
|
|
||||||
|
|
||||||
|
var count = 0;
|
||||||
|
var generalSectionData = [ ];
|
||||||
|
var storeId = [ ];
|
||||||
|
const len = Object.keys(tempData).length - 1;
|
||||||
|
for (const [keys, values] of Object.entries(tempData)) {
|
||||||
|
count++
|
||||||
|
if (Array.isArray(values) == true )
|
||||||
|
{
|
||||||
|
values.forEach(async(values) => {
|
||||||
|
if (keys == 'section1') { generalSectionData = await GeneralSection.create( values ); storeId = await GeneralSection.findOne({ where : { pd_id : generalSectionData.pd_id , is_active : 1 }}); };
|
||||||
|
if (keys == 'section2') { Object.assign(values, { pd_id: storeId.pd_id }); await FundRequirement.create( values ) };
|
||||||
|
if (keys == 'section3') { Object.assign(values, { pd_id: storeId.pd_id }); await DetailsOfKeyShareHolder.create( values) };
|
||||||
|
if (keys == 'section4') { Object.assign(values, { pd_id: storeId.pd_id }); await BreifOfBusiness.create( values) };
|
||||||
|
if (keys == 'section5') { Object.assign(values, { pd_id: storeId.pd_id }); await FinancialInformation.create( values) };
|
||||||
|
if (keys == 'section6') { Object.assign(values, { pd_id: storeId.pd_id }); await PropertyInformationn.create( values) };
|
||||||
|
if (keys == 'section7') { Object.assign(values, { pd_id: storeId.pd_id }); await FinalRemarks.create( values) };
|
||||||
|
if (keys == 'section8') { Object.assign(values, { pd_id: storeId.pd_id }); await OfficerDetails.create( values) };
|
||||||
|
// if (keys == 'section9') { Object.assign(values, { pd_id: storeId.pd_id }); await Photograph.create( values) };
|
||||||
|
if (keys == 'section10') { Object.assign(values, { pd_id: storeId.pd_id }); await InstitutionDetail.create( values) };
|
||||||
|
if (keys == 'section11') { Object.assign(values, { pd_id: storeId.pd_id }); await ProductInformation.create( values) };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (keys == 'section1') { id = await GeneralSection.create( values ); storeId = await GeneralSection.findOne({ where : { pd_id : id.pd_id , is_active : 1 }}); };
|
||||||
|
if (keys == 'section2') { Object.assign(values, { pd_id: storeId.pd_id }); await FundRequirement.create( values ) };
|
||||||
|
if (keys == 'section3') { Object.assign(values, { pd_id: storeId.pd_id }); await DetailsOfKeyShareHolder.create( values) };
|
||||||
|
if (keys == 'section4') { Object.assign(values, { pd_id: storeId.pd_id }); await BreifOfBusiness.create( values) };
|
||||||
|
if (keys == 'section5') { Object.assign(values, { pd_id: storeId.pd_id }); await FinancialInformation.create( values) };
|
||||||
|
if (keys == 'section6') { Object.assign(values, { pd_id: storeId.pd_id }); await PropertyInformationn.create( values) };
|
||||||
|
if (keys == 'section7') { Object.assign(values, { pd_id: storeId.pd_id }); await FinalRemarks.create( values) };
|
||||||
|
if (keys == 'section8') { Object.assign(values, { pd_id: storeId.pd_id }); await OfficerDetails.create( values) };
|
||||||
|
// if (keys == 'section9') { Object.assign(values, { pd_id: storeId.pd_id }); await Photograph.create( values) };
|
||||||
|
if (keys == 'section10') { Object.assign(values, { pd_id: storeId.pd_id }); await InstitutionDetail.create( values) };
|
||||||
|
if (keys == 'section11') { Object.assign(values, { pd_id: storeId.pd_id }); await ProductInformation.create( values) };
|
||||||
|
}
|
||||||
|
if (len == count - 1 )
|
||||||
|
{
|
||||||
|
var resData = await GeneralSection.findAll({ where : { pd_id : storeId.pd_id , is_active : 1 },
|
||||||
|
include : [ {model: FundRequirement }, {model: DetailsOfKeyShareHolder }, {model: DetailsOfKeyShareHolder }, {model: BreifOfBusiness }, {model: FinancialInformation }, {model: PropertyInformationn }, {model: FinalRemarks }, {model: OfficerDetails }, {model: Photograph }, {model: InstitutionDetail }, {model: ProductInformation }]
|
||||||
|
})
|
||||||
|
res.send(resData)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
26
app/models/BreifOfBusiness.js
Normal file
26
app/models/BreifOfBusiness.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
'use strict'
|
||||||
|
const { Model } = require('sequelize')
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
class BreifOfBusiness extends Model {
|
||||||
|
|
||||||
|
}
|
||||||
|
BreifOfBusiness.init(
|
||||||
|
{
|
||||||
|
pd_id: { type: DataTypes.INTEGER },
|
||||||
|
nature_of_business : { type: DataTypes.STRING },
|
||||||
|
brief_business_service: { type: DataTypes.STRING },
|
||||||
|
product_service_type: { type: DataTypes.STRING },
|
||||||
|
other_information: { type: DataTypes.STRING },
|
||||||
|
createdby: { type: DataTypes.INTEGER },
|
||||||
|
updatedby: { type: DataTypes.INTEGER }
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sequelize,
|
||||||
|
tableName: 'sales_brief_of_the_business_or_service',
|
||||||
|
modelName: 'BreifOfBusiness',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return BreifOfBusiness
|
||||||
|
}
|
||||||
40
app/models/BusinessAsset.js
Normal file
40
app/models/BusinessAsset.js
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
'use strict'
|
||||||
|
const { Model } = require('sequelize')
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
class BusinessAsset extends Model {
|
||||||
|
|
||||||
|
}
|
||||||
|
BusinessAsset.init(
|
||||||
|
{
|
||||||
|
pd_id: { type: DataTypes.INTEGER },
|
||||||
|
initiated_address: { type: DataTypes.STRING },
|
||||||
|
is_business_address: { type: DataTypes.STRING },
|
||||||
|
business_months: { type: DataTypes.INTEGER },
|
||||||
|
business_years: { type: DataTypes.INTEGER },
|
||||||
|
business_is_pd_visited: { type: DataTypes.STRING },
|
||||||
|
business_pd_visited_remark: { type: DataTypes.STRING },
|
||||||
|
business_ownership_type: { type: DataTypes.STRING },
|
||||||
|
business_approximate_market_value: { type: DataTypes.INTEGER },
|
||||||
|
business_name_of_the_owner: { type: DataTypes.STRING },
|
||||||
|
business_vintage: { type: DataTypes.INTEGER },
|
||||||
|
business_purchase_year: { type: DataTypes.INTEGER },
|
||||||
|
business_emi: { type: DataTypes.INTEGER },
|
||||||
|
business_monthly_rented_amt: { type: DataTypes.INTEGER },
|
||||||
|
asset_info_available: { type: DataTypes.STRING },
|
||||||
|
business_assets_mode: { type: DataTypes.STRING },
|
||||||
|
other_asset_description: { type: DataTypes.STRING },
|
||||||
|
company_name: { type: DataTypes.STRING },
|
||||||
|
createdby: { type: DataTypes.INTEGER },
|
||||||
|
updatedby: { type: DataTypes.INTEGER }
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sequelize,
|
||||||
|
tableName: 'credit_business_assets',
|
||||||
|
modelName: 'BusinessAsset',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
return BusinessAsset
|
||||||
|
}
|
||||||
27
app/models/DetailsOfKeyShareHolder.js
Normal file
27
app/models/DetailsOfKeyShareHolder.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
'use strict'
|
||||||
|
const { Model } = require('sequelize')
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
class DetailsOfKeyShareHolder extends Model {
|
||||||
|
|
||||||
|
}
|
||||||
|
DetailsOfKeyShareHolder.init(
|
||||||
|
{
|
||||||
|
pd_id: { type: DataTypes.INTEGER },
|
||||||
|
name: { type: DataTypes.STRING },
|
||||||
|
share_holding: { type: DataTypes.INTEGER },
|
||||||
|
vintage_in_current_biz: { type: DataTypes.INTEGER },
|
||||||
|
total_work_exp: { type: DataTypes.INTEGER },
|
||||||
|
started_biz: { type: DataTypes.STRING },
|
||||||
|
createdby: { type: DataTypes.INTEGER },
|
||||||
|
updatedby: { type: DataTypes.INTEGER }
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sequelize,
|
||||||
|
tableName: 'sales_details_of_key_stakeholders',
|
||||||
|
modelName: 'DetailsOfKeyShareHolder',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return DetailsOfKeyShareHolder
|
||||||
|
}
|
||||||
29
app/models/FinancialInformation.js
Normal file
29
app/models/FinancialInformation.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
'use strict'
|
||||||
|
const { Model } = require('sequelize')
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
class FinancialInformation extends Model {
|
||||||
|
|
||||||
|
}
|
||||||
|
FinancialInformation.init(
|
||||||
|
{
|
||||||
|
pd_id: { type: DataTypes.INTEGER },
|
||||||
|
fy: { type: DataTypes.STRING },
|
||||||
|
sales_revenue: { type: DataTypes.INTEGER },
|
||||||
|
net_profit: { type: DataTypes.INTEGER },
|
||||||
|
income_considered: { type: DataTypes.INTEGER },
|
||||||
|
income_assessment_program_recommended: { type: DataTypes.STRING },
|
||||||
|
fixed_obligations: { type: DataTypes.INTEGER },
|
||||||
|
equipment_contribution_turnover: { type: DataTypes.STRING },
|
||||||
|
createdby: { type: DataTypes.INTEGER },
|
||||||
|
updatedby: { type: DataTypes.INTEGER }
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sequelize,
|
||||||
|
tableName: 'sales_financial_information',
|
||||||
|
modelName: 'FinancialInformation',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return FinancialInformation
|
||||||
|
}
|
||||||
26
app/models/FundRequirement.js
Normal file
26
app/models/FundRequirement.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
'use strict'
|
||||||
|
const { Model } = require('sequelize')
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
class FundRequirement extends Model {
|
||||||
|
|
||||||
|
}
|
||||||
|
FundRequirement.init(
|
||||||
|
{
|
||||||
|
pd_id: { type: DataTypes.INTEGER },
|
||||||
|
loan_amount_applied: { type: DataTypes.INTEGER },
|
||||||
|
total_fund_requirement: { type: DataTypes.INTEGER },
|
||||||
|
loan_tenure: { type: DataTypes.INTEGER },
|
||||||
|
loan_purpose: { type: DataTypes.STRING },
|
||||||
|
createdby: { type: DataTypes.INTEGER },
|
||||||
|
updatedby: { type: DataTypes.INTEGER }
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sequelize,
|
||||||
|
tableName: 'sales_fund_requirement',
|
||||||
|
modelName: 'FundRequirement',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return FundRequirement
|
||||||
|
}
|
||||||
88
app/models/GeneralSection.js
Normal file
88
app/models/GeneralSection.js
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
'use strict'
|
||||||
|
const { Model } = require('sequelize')
|
||||||
|
const { sequelize, GeneralSection ,FundRequirement , DetailsOfKeyShareHolder , BreifOfBusiness , FinancialInformation , PropertyInformationn , FinalRemarks , OfficerDetails , Photograph , InstitutionDetail , ProductInformation} = require('../models');
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
class GeneralSection extends Model {
|
||||||
|
|
||||||
|
}
|
||||||
|
GeneralSection.init(
|
||||||
|
{
|
||||||
|
pd_id: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
autoIncrement : true,
|
||||||
|
primaryKey: true
|
||||||
|
},
|
||||||
|
application_id: { type: DataTypes.STRING },
|
||||||
|
main_loan_applicant: { type: DataTypes.STRING },
|
||||||
|
company_name: { type: DataTypes.STRING },
|
||||||
|
person_met_during_visit: { type: DataTypes.STRING },
|
||||||
|
person_met_designation: { type: DataTypes.STRING },
|
||||||
|
person_met_contact_no: { type: DataTypes.INTEGER },
|
||||||
|
address_visited: { type: DataTypes.STRING },
|
||||||
|
state: { type: DataTypes.STRING },
|
||||||
|
city: { type: DataTypes.STRING },
|
||||||
|
pincode: { type: DataTypes.INTEGER },
|
||||||
|
constitution: { type: DataTypes.STRING },
|
||||||
|
applicant_qualification: { type: DataTypes.STRING },
|
||||||
|
mother_name: { type: DataTypes.STRING },
|
||||||
|
official_emailid: { type: DataTypes.STRING },
|
||||||
|
current_residence_address: { type: DataTypes.STRING },
|
||||||
|
current_residence_ownership: { type: DataTypes.STRING },
|
||||||
|
business_office_address: { type: DataTypes.STRING },
|
||||||
|
createdby: { type: DataTypes.INTEGER },
|
||||||
|
updatedby: { type: DataTypes.INTEGER }
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sequelize,
|
||||||
|
tableName: 'sales_general_section',
|
||||||
|
modelName: 'GeneralSection',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
GeneralSection.associate = models => {
|
||||||
|
GeneralSection.hasMany(models.FundRequirement, {
|
||||||
|
foreignKey: 'pd_id',
|
||||||
|
sourceKey : 'pd_id'
|
||||||
|
});
|
||||||
|
GeneralSection.hasMany(models.DetailsOfKeyShareHolder, {
|
||||||
|
foreignKey: 'pd_id',
|
||||||
|
sourceKey : 'pd_id'
|
||||||
|
});
|
||||||
|
GeneralSection.hasMany(models.BreifOfBusiness, {
|
||||||
|
foreignKey: 'pd_id',
|
||||||
|
sourceKey : 'pd_id'
|
||||||
|
});
|
||||||
|
GeneralSection.hasMany(models.FinancialInformation, {
|
||||||
|
foreignKey: 'pd_id',
|
||||||
|
sourceKey : 'pd_id'
|
||||||
|
});
|
||||||
|
GeneralSection.hasMany(models.PropertyInformationn, {
|
||||||
|
foreignKey: 'pd_id',
|
||||||
|
sourceKey : 'pd_id'
|
||||||
|
});
|
||||||
|
GeneralSection.hasMany(models.FinalRemarks, {
|
||||||
|
foreignKey: 'pd_id',
|
||||||
|
sourceKey : 'pd_id'
|
||||||
|
});
|
||||||
|
GeneralSection.hasMany(models.OfficerDetails, {
|
||||||
|
foreignKey: 'pd_id',
|
||||||
|
sourceKey : 'pd_id'
|
||||||
|
});
|
||||||
|
GeneralSection.hasMany(models.Photograph, {
|
||||||
|
foreignKey: 'pd_id',
|
||||||
|
sourceKey : 'pd_id'
|
||||||
|
});
|
||||||
|
GeneralSection.hasMany(models.InstitutionDetail, {
|
||||||
|
foreignKey: 'pd_id',
|
||||||
|
sourceKey : 'pd_id'
|
||||||
|
});
|
||||||
|
GeneralSection.hasMany(models.ProductInformation, {
|
||||||
|
foreignKey: 'pd_id',
|
||||||
|
sourceKey : 'pd_id'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return GeneralSection
|
||||||
|
}
|
||||||
31
app/models/InstitutionDetails.js
Normal file
31
app/models/InstitutionDetails.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
'use strict'
|
||||||
|
const { Model } = require('sequelize')
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
class InstitutionDetail extends Model {
|
||||||
|
|
||||||
|
}
|
||||||
|
InstitutionDetail.init(
|
||||||
|
{
|
||||||
|
pd_id: { type: DataTypes.INTEGER },
|
||||||
|
institution_type: { type: DataTypes.STRING },
|
||||||
|
about_locality: { type: DataTypes.STRING },
|
||||||
|
instituion_vitage: { type: DataTypes.STRING },
|
||||||
|
opening_new_branch: { type: DataTypes.STRING },
|
||||||
|
property_ownership: { type: DataTypes.STRING },
|
||||||
|
area_sq_feet: { type: DataTypes.INTEGER },
|
||||||
|
floor: { type: DataTypes.INTEGER },
|
||||||
|
staff_observer_number: { type: DataTypes.INTEGER },
|
||||||
|
business_activity_seen: { type: DataTypes.STRING },
|
||||||
|
createdby: { type: DataTypes.INTEGER },
|
||||||
|
updatedby: { type: DataTypes.INTEGER }
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sequelize,
|
||||||
|
tableName: 'sales_institution_details',
|
||||||
|
modelName: 'InstitutionDetail',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return InstitutionDetail
|
||||||
|
}
|
||||||
25
app/models/OfficerDetails.js
Normal file
25
app/models/OfficerDetails.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
'use strict'
|
||||||
|
const { Model } = require('sequelize')
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
class OfficerDetails extends Model {
|
||||||
|
|
||||||
|
}
|
||||||
|
OfficerDetails.init(
|
||||||
|
{
|
||||||
|
pd_id: { type: DataTypes.INTEGER },
|
||||||
|
name_of_sales_team_member: { type: DataTypes.STRING },
|
||||||
|
designation: { type: DataTypes.STRING },
|
||||||
|
date: { type: DataTypes.STRING },
|
||||||
|
createdby: { type: DataTypes.INTEGER },
|
||||||
|
updatedby: { type: DataTypes.INTEGER }
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sequelize,
|
||||||
|
tableName: 'sales_officer_details',
|
||||||
|
modelName: 'OfficerDetails',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return OfficerDetails
|
||||||
|
}
|
||||||
29
app/models/Photograph.js
Normal file
29
app/models/Photograph.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
'use strict'
|
||||||
|
const { Model } = require('sequelize')
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
class Photograph extends Model {
|
||||||
|
|
||||||
|
}
|
||||||
|
Photograph.init(
|
||||||
|
{
|
||||||
|
pd_id: { type: DataTypes.INTEGER },
|
||||||
|
selfie_with_person_met: { type: DataTypes.STRING },
|
||||||
|
hospital_building: { type: DataTypes.STRING },
|
||||||
|
approach_to_pd_location: { type: DataTypes.STRING },
|
||||||
|
name_board_seen: { type: DataTypes.STRING },
|
||||||
|
stock_image: { type: DataTypes.STRING },
|
||||||
|
workplace_interior_image: { type: DataTypes.STRING },
|
||||||
|
institute_interior: { type: DataTypes.STRING },
|
||||||
|
createdby: { type: DataTypes.INTEGER },
|
||||||
|
updatedby: { type: DataTypes.INTEGER }
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sequelize,
|
||||||
|
tableName: 'sales_photograph',
|
||||||
|
modelName: 'Photograph',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return Photograph
|
||||||
|
}
|
||||||
25
app/models/ProductInformation.js
Normal file
25
app/models/ProductInformation.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
'use strict'
|
||||||
|
const { Model } = require('sequelize')
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
class ProductInformation extends Model {
|
||||||
|
|
||||||
|
}
|
||||||
|
ProductInformation.init(
|
||||||
|
{
|
||||||
|
pd_id: { type: DataTypes.INTEGER },
|
||||||
|
equipment_list: { type: DataTypes.STRING },
|
||||||
|
tot_product_invoice_value: { type: DataTypes.INTEGER },
|
||||||
|
vendor_list: { type: DataTypes.STRING },
|
||||||
|
createdby: { type: DataTypes.INTEGER },
|
||||||
|
updatedby: { type: DataTypes.INTEGER }
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sequelize,
|
||||||
|
tableName: 'sales_product_information',
|
||||||
|
modelName: 'ProductInformation',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return ProductInformation
|
||||||
|
}
|
||||||
31
app/models/PropertyInformation.js
Normal file
31
app/models/PropertyInformation.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
'use strict'
|
||||||
|
const { Model } = require('sequelize')
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
class PropertyInformationn extends Model {
|
||||||
|
|
||||||
|
}
|
||||||
|
PropertyInformationn.init(
|
||||||
|
{
|
||||||
|
pd_id: { type: DataTypes.INTEGER },
|
||||||
|
property_address: { type: DataTypes.STRING },
|
||||||
|
property_type: { type: DataTypes.STRING },
|
||||||
|
occupancy_status: { type: DataTypes.STRING },
|
||||||
|
permitted_property_usage: { type: DataTypes.STRING },
|
||||||
|
actual_property_usage: { type: DataTypes.STRING },
|
||||||
|
built_up_area: { type: DataTypes.STRING },
|
||||||
|
built_up_area_uom: { type: DataTypes.STRING },
|
||||||
|
approx_mkt_val: { type: DataTypes.INTEGER },
|
||||||
|
property_Ownership_Status: { type: DataTypes.STRING },
|
||||||
|
createdby: { type: DataTypes.INTEGER },
|
||||||
|
updatedby: { type: DataTypes.INTEGER }
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sequelize,
|
||||||
|
tableName: 'sales_property_information',
|
||||||
|
modelName: 'PropertyInformationn',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return PropertyInformationn
|
||||||
|
}
|
||||||
31
app/models/Test.js
Normal file
31
app/models/Test.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
'use strict'
|
||||||
|
const { Model } = require('sequelize')
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
class Test extends Model {
|
||||||
|
/**
|
||||||
|
* Helper method for defining associations.
|
||||||
|
* This method is not a part of Sequelize lifecycle.
|
||||||
|
* The `models/index` file will call this method automatically.
|
||||||
|
*/
|
||||||
|
// define association here
|
||||||
|
// static associate({ Financials }) {
|
||||||
|
// this.hasMany(Financials, { foreignKey: 'entity_id', as: 'financialsData' })
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
Test.init(
|
||||||
|
{
|
||||||
|
losid: { type: DataTypes.STRING },
|
||||||
|
createdby: { type: DataTypes.INTEGER },
|
||||||
|
updatedby: { type: DataTypes.INTEGER },
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sequelize,
|
||||||
|
tableName: 'test',
|
||||||
|
modelName: 'Test',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return Test
|
||||||
|
}
|
||||||
39
app/models/index.js
Normal file
39
app/models/index.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const Sequelize = require('sequelize');
|
||||||
|
const basename = path.basename(__filename);
|
||||||
|
const env = process.env.NODE_ENV || 'development';
|
||||||
|
const config = require(__dirname + '/../config/db.config.js')[env];
|
||||||
|
//console.log(env);
|
||||||
|
//console.log(config);
|
||||||
|
const db = {};
|
||||||
|
|
||||||
|
let sequelize;
|
||||||
|
if (config.use_env_variable) {
|
||||||
|
sequelize = new Sequelize(process.env[config.use_env_variable], config);
|
||||||
|
} else {
|
||||||
|
sequelize = new Sequelize(config.database, config.username, config.password, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
fs
|
||||||
|
.readdirSync(__dirname)
|
||||||
|
.filter(file => {
|
||||||
|
return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js');
|
||||||
|
})
|
||||||
|
.forEach(file => {
|
||||||
|
const model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes);
|
||||||
|
db[model.name] = model;
|
||||||
|
});
|
||||||
|
|
||||||
|
Object.keys(db).forEach(modelName => {
|
||||||
|
if (db[modelName].associate) {
|
||||||
|
db[modelName].associate(db);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
db.sequelize = sequelize;
|
||||||
|
db.Sequelize = Sequelize;
|
||||||
|
|
||||||
|
module.exports = db;
|
||||||
32
app/routes/routes.js
Normal file
32
app/routes/routes.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
module.exports = app => {
|
||||||
|
const request = require("request");
|
||||||
|
const cors=require('cors');
|
||||||
|
const Mycontroller = require("../controllers/test.controller.js");
|
||||||
|
const { logMsg } = require('../services/logger.js');
|
||||||
|
var router = require("express").Router();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @swagger
|
||||||
|
* /api/demo:
|
||||||
|
* get:
|
||||||
|
* summary: Demo Api
|
||||||
|
* description: Welcome Message
|
||||||
|
* responses:
|
||||||
|
* 200:
|
||||||
|
* description: success
|
||||||
|
*/
|
||||||
|
router.get("/demo", Mycontroller.Welcome);
|
||||||
|
|
||||||
|
|
||||||
|
router.get('/salespd',Mycontroller.SalesPd)
|
||||||
|
|
||||||
|
|
||||||
|
// routes started here
|
||||||
|
app.use('/api', router);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
27
app/services/logger.js
Normal file
27
app/services/logger.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Configurations of logger.
|
||||||
|
*/
|
||||||
|
var winston = require('winston');
|
||||||
|
require('winston-daily-rotate-file');
|
||||||
|
|
||||||
|
var transport = new winston.transports.DailyRotateFile({
|
||||||
|
filename: 'storage/log/msg.log',
|
||||||
|
datePattern: 'YYYY-MM-DD',
|
||||||
|
zippedArchive: true,
|
||||||
|
maxSize: '20m',
|
||||||
|
maxFiles: '14d'
|
||||||
|
});
|
||||||
|
|
||||||
|
transport.on('rotate', function(oldFilename, newFilename) {
|
||||||
|
// do something fun
|
||||||
|
});
|
||||||
|
|
||||||
|
const logger = winston.createLogger({
|
||||||
|
transports: [
|
||||||
|
transport
|
||||||
|
]
|
||||||
|
});
|
||||||
|
module.exports = {
|
||||||
|
'logMsg': logger,
|
||||||
|
};
|
||||||
|
|
||||||
8798
package-lock.json
generated
Normal file
8798
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
30
package.json
Normal file
30
package.json
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"name": "smc_cet_salespd_backend",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"main": "server.js",
|
||||||
|
"scripts": {
|
||||||
|
"start": "nodemon server.js"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"body-parser": "^1.19.0",
|
||||||
|
"cors": "^2.8.5",
|
||||||
|
"dotenv": "^10.0.0",
|
||||||
|
"express": "^4.17.1",
|
||||||
|
"lodash": "^4.17.21",
|
||||||
|
"log4js": "^6.3.0",
|
||||||
|
"mssql": "^7.2.0",
|
||||||
|
"request": "^2.88.2",
|
||||||
|
"sequelize": "^6.6.5",
|
||||||
|
"swagger-jsdoc": "^6.1.0",
|
||||||
|
"swagger-ui-express": "^4.1.6",
|
||||||
|
"winston": "^3.3.3",
|
||||||
|
"winston-daily-rotate-file": "^4.5.5"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"nodemon": "^2.0.12"
|
||||||
|
},
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
63
server.js
Normal file
63
server.js
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
require('dotenv').config();
|
||||||
|
const express = require('express')
|
||||||
|
const app = express()
|
||||||
|
//it is used to clear cache
|
||||||
|
app.use(function(req, res, next) {
|
||||||
|
res.set("Cache-Control", "no-cache, no-store, must-revalidate, max-age=0")
|
||||||
|
res.set("Pragma", "no-cache")
|
||||||
|
res.set("Expires", 0)
|
||||||
|
next()
|
||||||
|
})
|
||||||
|
const {logMsg} = require('./app/services/logger.js');
|
||||||
|
|
||||||
|
const swaggerJsdoc = require('swagger-jsdoc');
|
||||||
|
const swaggerUi = require('swagger-ui-express');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
definition: {
|
||||||
|
openapi: '3.0.0',
|
||||||
|
info: {
|
||||||
|
title: 'Smc_cet_financials',
|
||||||
|
version: '1.0.0',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
apis: ['./app/routes/routes.js'], // files containing annotations as above
|
||||||
|
};
|
||||||
|
|
||||||
|
const swaggerDocument = swaggerJsdoc(options);
|
||||||
|
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @openapi
|
||||||
|
* /:
|
||||||
|
* get:
|
||||||
|
* description: Welcome to swagger-jsdoc!
|
||||||
|
* responses:
|
||||||
|
* 200:
|
||||||
|
* description: Returns a mysterious string.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
app.get("/", (req, res) => {
|
||||||
|
res.json({ message: "Welcome to the application." });
|
||||||
|
logMsg.info("Server Sent A Welcome to the application!");
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
app.use(express.json())
|
||||||
|
app.use(express.urlencoded({ extended: true }));
|
||||||
|
|
||||||
|
|
||||||
|
require("./app/routes/routes.js")(app);
|
||||||
|
|
||||||
|
const PORT_NUMBER = process.env.SERVER_PORT
|
||||||
|
app.listen({ port: PORT_NUMBER }, async () => {
|
||||||
|
console.log('Server up on http://localhost:8080')
|
||||||
|
|
||||||
|
//await sequelize.authenticate()
|
||||||
|
})
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user