Skip to content

Commit 39ace26

Browse files
committed
extended the mail functionality
1 parent ad1143a commit 39ace26

File tree

3 files changed

+112
-18
lines changed

3 files changed

+112
-18
lines changed

app/controllers/company.controller.js

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const User = require('../models/user.model');
2+
const Mail = require('../services/mailer.service');
23
const Company = require('../models/company.model');
34
const mongoose = require('mongoose');
45

@@ -45,8 +46,68 @@ exports.add = (req, res) => {
4546

4647
Company
4748
.create(_b)
48-
.then(data => {
49+
.then(async data => {
4950
res.status(200).json({ success : true, message : 'Successfully new company added.'})
51+
52+
const batch = Number(_b.passout_batch);
53+
54+
let email = [];
55+
56+
// eligibility
57+
for(let course in _b.eligibility){
58+
if(course == "UG"){
59+
email.push(batch-4+"[email protected]");
60+
} else if(course == "MTech"){
61+
email.push(batch-2+"[email protected]");
62+
} else if(course == "MPlan"){
63+
email.push(batch-2+"[email protected]");
64+
} else if(course == "MSc"){
65+
email.push(batch-2+"[email protected]");
66+
} else if(course == "MBA"){
67+
email.push(batch-2+"[email protected]");
68+
}
69+
}
70+
71+
//package details
72+
if(!_b.package){
73+
_b.package = {
74+
UG: {ctc: 'NA'},
75+
MTech: {ctc: 'NA'},
76+
MPlan: {ctc: 'NA'},
77+
MSc: {ctc: 'NA'},
78+
MBA: {ctc: 'NA'}
79+
};
80+
}
81+
try{
82+
_b.package.UG.ctc = _b.package.UG.ctc;
83+
} catch(err){
84+
_b.package.UG = {ctc: 'NA'};
85+
}
86+
try{
87+
_b.package.MTech.ctc = _b.package.MTech.ctc;
88+
} catch(err){
89+
_b.package.MTech = {ctc: 'NA'};
90+
}
91+
try {
92+
_b.package.MPlan.ctc = _b.package.MPlan.ctc;
93+
} catch(err){
94+
_b.package.MPlan = {ctc: 'NA'};
95+
}
96+
try {
97+
_b.package.MSc.ctc = _b.package.MSc.ctc;
98+
} catch(err){
99+
_b.package.MSc = {ctc: 'NA'};
100+
}
101+
try {
102+
_b.package.MBA.ctc = _b.package.MBA.ctc;
103+
} catch(err){
104+
_b.package.MBA = {ctc: 'NA'};
105+
}
106+
107+
data.email = email;
108+
data.package = _b.package;
109+
110+
const notif = await Mail.sendDM(data, 'companyAdded');
50111
})
51112
.catch(err => {
52113
console.error(err);

app/models/company.model.js

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,20 @@ var companySchema = new mongoose.Schema({
99
required : true
1010
},
1111
company_website_url : {
12-
type : String
12+
type : String,
13+
default : ' '
1314
},
1415
organization_type : {
15-
type : String
16+
type : String,
17+
default : ' '
1618
},
1719
industry_sector : {
18-
type : String
20+
type : String,
21+
default : ' '
1922
},
2023
about_company : {
21-
type : String
24+
type : String,
25+
default : ' '
2226
},
2327

2428
// Job Profile
@@ -31,56 +35,69 @@ var companySchema = new mongoose.Schema({
3135
required : true
3236
},
3337
recruitment : {
34-
type : String
38+
type : String,
39+
required : true
3540
},
3641
duration : {
37-
type : String
42+
type : String,
43+
default : ' '
3844
},
3945
posting_location : {
40-
type : String
46+
type : String,
47+
default : ' '
4148
},
4249
joining_date : {
4350
type : Date
4451
},
4552
job_description : {
46-
type : String
53+
type : String,
54+
default : ' '
4755
},
4856

4957
// student eligibility
5058
eligibility : {
5159
type : Object
5260
},
5361
min_cgpa : {
54-
type : String // todo convert float
62+
type : String, // todo convert float
63+
default : 'NA'
5564
},
5665
min_10_percent : {
57-
type : String
66+
type : String,
67+
default : 'NA'
5868
},
5969
min_12_percent : {
60-
type : String
70+
type : String,
71+
default : 'NA'
6172
},
6273
medical_requirement : {
63-
type : String
74+
type : String,
75+
default : 'NA'
6476
},
6577
service_agreement : {
66-
type : String
78+
type : String,
79+
default : 'NA'
6780
},
6881
service_agreement_duration : {
69-
type : String
82+
type : String,
83+
default : 'NA'
7084
},
7185
other_eligibility : {
72-
type : String
86+
type : String,
87+
default : 'NA'
7388
},
7489

7590
// Package Details
7691
package : {
7792
type : Object
7893
},
7994
company_accommodation : {
80-
type : String
95+
type : String,
96+
default : 'NA'
8197
},
8298
other_facility : {
83-
type : String
99+
type : String,
100+
default : 'NA'
84101
},
85102

86103
// Selection Process

app/services/template.service.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,22 @@ exports.getEmailOpts = (data, mailType) => {
4646
};
4747
break;
4848

49+
case 'companyAdded':
50+
return {
51+
from: from,
52+
to: data.email,
53+
subject: 'Company Specific Registration: ' + data.company_name,
54+
text: 'Dear Students,\nCompany Name: '+data.company_name+'\nProfile: '+data.job_profile+'\nJob Location: '+data.posting_locatioin+'\nDeadline: '+data.deadline_date+'\nWith Regards, Prof. Mahendar Choudhary',
55+
html: 'Dear Students,<br><br><table border="1|0" style="border-collapse: collapse"><tr><td><strong>Company Name:</strong></td><td>'+data.company_name+'</td></tr><tr><td><strong>Company URL:</strong></td><td>'+data.company_website_url+'</td></tr><tr><td><strong>Organization Type:</strong></td><td>'
56+
+data.organization_type+'</td></tr><tr><td><strong>Industry Sector:</strong></td><td>'+data.industry_sector+'</td></tr><tr><td><strong>About Company:</strong></td><td>'+data.about_company+'</td></tr><tr><td><strong>Profile:</strong></td><td>'+data.job_profile+'</td></tr><tr><td><strong>Passout Batch:</strong></td><td>'
57+
+data.passout_batch+'</td></tr><tr><td><strong>Recruitment Type:</strong></td><td>'+data.recruitment+'</td></tr><tr><td><strong>Duration:</strong></td><td>'+data.duration+'</td></tr><tr><td><strong>Job Location:</strong></td><td>'+data.posting_location+'</td></tr><tr><td><strong>Job Description:</strong></td><td>'
58+
+data.job_description+'</td></tr><tr><td><strong>Min CGPA:</strong></td><td>'+data.min_cgpa+'</td></tr><tr><td><strong>Min 10%:</strong></td><td>'+data.min_10_percent+'</td></tr><tr><td><strong>Min 12%:</strong></td><td>'+data.min_12_percent+'</td></tr><tr><td><strong>Medical Requirement:</strong></td><td>'
59+
+data.medical_requirement+'</td></tr><tr><td><strong>Service Agreement:</strong></td><td>'+data.service_agreement+'</td></tr><tr><td><strong>Duration of Agreement:</strong></td><td>'+data.service_agreement_duration+'</td></tr><tr><td><strong>Other Eligibility:</strong></td><td>'
60+
+data.other_eligibility+'</td></tr><tr><td><strong>Package:</strong></td><td>UG: '+data.package.UG.ctc+'<br>MTech: '+data.package.MTech.ctc+'<br>MPlan: '+data.package.MPlan.ctc+'<br>MSc: '+data.package.MSc.ctc+'<br>MBA: '+data.package.MBA.ctc+'</td></tr><tr><td><strong>Company Accommodation:</strong></td><td>'
61+
+data.company_accommodation+'</td></tr><tr><td><strong>Other Facility:</strong></td><td>'+data.other_facility+'</td></tr><tr><td><strong>Deadline:</strong></td><td>'+data.deadline_date+'</td></tr></table><br><a href="'+baseUrl+"/company/"+data._id+'"><strong>Link to register</strong></a><br><br>'+email_signature
62+
};
63+
break;
64+
4965
default:
5066
return {}
5167
}

0 commit comments

Comments
 (0)