Skip to content

Commit b424efc

Browse files
committed
New models and routs
1 parent 6a94fa2 commit b424efc

12 files changed

+313
-2
lines changed

app.js

+7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ const photoGalleryRouter = require("./routes/photoGallery");
1818
const footerRouter = require("./routes/footer");
1919
const aboutRouter = require("./routes/about");
2020
const testimonialRouter = require("./routes/testimonial");
21+
const specialCentresRouter = require('./routes/specialCentres');
2122
const studentTeamRouter = require("./routes/studentTeam");
23+
const academicnoticesRouter = require("./routes/academicnotices");
24+
const studyProgramRouter = require("./routes/studyprog");
2225
const clubRouter = require("./routes/club");
2326
const upcomingEventRouter = require("./routes/upcomingEvent");
2427
const departmentRouter = require("./routes/departement");
@@ -37,6 +40,7 @@ bodyParser.urlencoded({ extended: true });
3740
app.use(bodyParser.json());
3841
app.use(compression());
3942
app.use(cookieParser());
43+
app.use(cors());
4044

4145
app.use((req, res, next) => {
4246
res.header("Access-Control-Allow-Origin", "*");
@@ -67,7 +71,10 @@ app.use("/ranking", rankingRouter);
6771
app.use("/yearlyRanking", yearlyRankingRouter);
6872
app.use("/timeline", timelineRouter);
6973
app.use("/publication", publicationRouter);
74+
app.use('/academicnotices',academicnoticesRouter);
75+
app.use('/specialCentres',specialCentresRouter);
7076
app.use("/tender", tenderRouter);
77+
app.use('/studyprogramme',studyProgramRouter);
7178
app.use("/researchHighlights", reasearchHighlights);
7279
app.use("/photoGallery", photoGalleryRouter);
7380
app.use("/footer", footerRouter);

controllers/academicCalendar.js

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ const addAcademicCalendar=async(req,res)=>{
1717
res.status(201).json(result);
1818
} catch (error) {
1919
res.status(400).json("Error: " + error);
20-
2120
}
2221
}
2322

controllers/academicnotices.js

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
const AcademicNotices= require('../models/academicnotices');
2+
3+
const getAllAcademicNotices=async(req,res)=>{
4+
try {
5+
const result=await AcademicNotices.find({show:true});
6+
res.status(200).json(result);
7+
} catch (error) {
8+
res.status(400).json("Error: " + error);
9+
}
10+
}
11+
12+
const getByIdAcademicNotices=async(req,res)=>{
13+
try {
14+
const result=await AcademicNotices.find(req.params.id);
15+
res.status(200).json(result);
16+
} catch (error) {
17+
res.status(400).json("Error: " + error);
18+
}
19+
}
20+
21+
const addAcademicNotices=async(req,res)=>{
22+
const academicNotices=new AcademicNotices({...req.body});
23+
24+
try {
25+
const result=await academicNotices.save();
26+
res.status(201).json(result)
27+
} catch (error) {
28+
res.status(400).json("Error: " + error);
29+
}
30+
}
31+
32+
const deleteAcademicNotices=async(req,res)=>{
33+
try {
34+
const result=await AcademicNotices.findByIdAndUpdate(req.params.id,{$set:{show:false}});
35+
res.status(200).json("AcademicNotices deleted succesfully")
36+
} catch (error) {
37+
res.status(400).json("Error: " + error);
38+
}
39+
}
40+
41+
const updateAcademicNotices=async(req,res)=>{
42+
try {
43+
const result=await AcademicNotices.findByIdAndUpdate(req.params.id,req.body);
44+
res.status(200).json("AcademicNotices updated succesfully")
45+
} catch (error) {
46+
res.status(400).json("Error: " + error);
47+
}
48+
}
49+
50+
module.exports={getAllAcademicNotices,getByIdAcademicNotices,updateAcademicNotices,deleteAcademicNotices,addAcademicNotices}
51+

controllers/specialCentres.js

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
const specialCentres = require('../models/specialCentres');
2+
3+
const getAllSpecialCentres=async(req,res)=>{
4+
try {
5+
const result=await specialCentres.find({show:true});
6+
res.status(200).json(result);
7+
} catch (error) {
8+
res.status(400).json("Error: " + error);
9+
}
10+
}
11+
12+
const getByDeptSpecialCentres=async(req,res)=>{
13+
try {
14+
const result=await specialCentres.find({show:true,shortterm:req.params.shortterm});
15+
res.status(200).json(result);
16+
} catch (error) {
17+
res.status(400).json("Error: " + error);
18+
}
19+
}
20+
21+
const addSpecialCentres=async(req,res)=>{
22+
const SpecialCentres=new specialCentres({...req.body});
23+
try {
24+
const result=await SpecialCentres.save();
25+
res.status(201).json(result)
26+
} catch (error) {
27+
res.status(400).json("Error: " + error);
28+
}
29+
}
30+
31+
const deleteSpecialCentres=async(req,res)=>{
32+
try {
33+
const result=await specialCentres.findByIdAndUpdate(req.params.id,{$set:{show:false}});
34+
res.status(200).json("SpecialCentres deleted succesfully")
35+
} catch (error) {
36+
res.status(400).json("Error: " + error);
37+
}
38+
}
39+
40+
const addFaculty=async(req,res)=>{
41+
try {
42+
const term = req.params.term;
43+
let result;
44+
45+
if(term=='faculties')
46+
result=await specialCentres.findOneAndUpdate({shortterm: req.params.shortterm},{$push: {faculties: req.body}});
47+
else if(term=='associate_faculties')
48+
result=await specialCentres.findOneAndUpdate({shortterm: req.params.shortterm},{$push: {associate_faculties: req.body}});
49+
else if(term=='workers')
50+
result=await specialCentres.findOneAndUpdate({shortterm: req.params.shortterm},{$push: {workers: req.body}});
51+
else if(term=='special_links')
52+
result=await specialCentres.findOneAndUpdate({shortterm: req.params.shortterm},{$push: {specialLinks: req.body}});
53+
res.status(200).json(result);
54+
} catch (error) {
55+
res.status(400).json("Error: " + error);
56+
}
57+
}
58+
59+
module.exports={getAllSpecialCentres,getByDeptSpecialCentres,addFaculty,deleteSpecialCentres,addSpecialCentres}

controllers/study_programmes.js

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
const studyProgrammes = require('../models/study_programmes');
2+
3+
const getAllstudyProgrammes=async(req,res)=>{
4+
try {
5+
const result=await studyProgrammes.find({show:true});
6+
res.status(200).json(result);
7+
} catch (error) {
8+
res.status(400).json("Error: " + error);
9+
}
10+
}
11+
12+
const getByDeptstudyProgrammes=async(req,res)=>{
13+
try {
14+
const result=await studyProgrammes.find({show:true,programmeName:req.params.dept});
15+
res.status(200).json(result);
16+
} catch (error) {
17+
res.status(400).json("Error: " + error);
18+
}
19+
}
20+
21+
const addstudyProgrammes=async(req,res)=>{
22+
const StudyProgrammes=new studyProgrammes({...req.body});
23+
try {
24+
const result=await StudyProgrammes.save();
25+
res.status(201).json(result)
26+
} catch (error) {
27+
res.status(400).json("Error: " + error);
28+
}
29+
}
30+
31+
const deletestudyProgrammes=async(req,res)=>{
32+
try {
33+
const result=await studyProgrammes.findByIdAndUpdate(req.params.id,{$set:{show:false}});
34+
res.status(200).json("studyProgrammes deleted succesfully")
35+
} catch (error) {
36+
res.status(400).json("Error: " + error);
37+
}
38+
}
39+
40+
const addStudyProgramme=async(req,res)=>{
41+
try {
42+
result=await studyProgrammes.findOneAndUpdate({programmeName: req.params.programmeName},{$push: {programmes: req.body}});
43+
res.status(200).json(result);
44+
} catch (error) {
45+
res.status(400).json("Error: " + error);
46+
}
47+
}
48+
49+
module.exports={getAllstudyProgrammes,getByDeptstudyProgrammes,addStudyProgramme,deletestudyProgrammes,addstudyProgrammes}

models/academicnotices.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const mongoose = require("mongoose");
2+
3+
const Schema = new mongoose.Schema({
4+
title: {
5+
type: String,
6+
},
7+
ref_no: {
8+
type: String,
9+
},
10+
date: {
11+
type: String,
12+
},
13+
url: {
14+
type: String,
15+
},
16+
show: { type: Boolean, default: true },
17+
});
18+
19+
module.exports = mongoose.model('AcadNotices', Schema);

models/specialCentres.js

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
const Mongoose = require('mongoose');
2+
3+
const Schema = new Mongoose.Schema({
4+
centrename: {
5+
type: String,
6+
required: true,
7+
},
8+
shortterm: {
9+
type: String,
10+
unique: true,
11+
},
12+
show:{
13+
type: Boolean,
14+
default: true,
15+
},
16+
faculties: [
17+
{
18+
name: String,
19+
designation: String,
20+
department: String,
21+
email_id: String,
22+
qualification: String,
23+
url: String
24+
}
25+
],
26+
associate_faculties: [
27+
{
28+
name: String,
29+
designation: String,
30+
department: String,
31+
email_id: String,
32+
qualification: String,
33+
url: String
34+
}
35+
],
36+
workers: [
37+
{
38+
name: String,
39+
designation: String,
40+
qualification: String,
41+
shopname: String,
42+
}
43+
],
44+
specialLinks:[
45+
{
46+
title: String,
47+
url: String
48+
}
49+
],
50+
}, {
51+
timestamps: true,
52+
});
53+
54+
module.exports = Mongoose.model('SpecialCentres', Schema)

models/study_programmes.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const mongoose = require('mongoose');
2+
3+
const Schema = new mongoose.Schema({
4+
programmeName:{
5+
type: String,
6+
unique: true,
7+
},
8+
show:{
9+
type: Boolean,
10+
default: true,
11+
},
12+
programmes:[
13+
{
14+
years: Number,
15+
list: [
16+
{
17+
title: String,
18+
url: String,
19+
}
20+
]
21+
}
22+
]
23+
})
24+
25+
module.exports = mongoose.model('StudyProg', Schema);

routes/academicnotices.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const express = require('express');
2+
const academicnotices = require('../controllers/academicnotices');
3+
//----------------------------------->
4+
5+
//Router
6+
const Router = express.Router();
7+
8+
Router.route('/').post(academicnotices.addAcademicNotices).get(academicnotices.getAllAcademicNotices);
9+
10+
Router.route('/get/all').get(academicnotices.getAllAcademicNotices);
11+
12+
Router.route('/:id').patch(academicnotices.updateAcademicNotices).post(academicnotices.deleteAcademicNotices);
13+
14+
15+
//Export----------------------------->
16+
module.exports = Router;

routes/specialCentres.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const express = require('express');
2+
const specialCentres = require('../controllers/specialCentres');
3+
//----------------------------------->
4+
5+
//Router
6+
const Router = express.Router();
7+
8+
Router.route('/').post(specialCentres.addSpecialCentres).get(specialCentres.getAllSpecialCentres);
9+
10+
Router.route('/get/all').get(specialCentres.getAllSpecialCentres);
11+
12+
Router.route('/getcentre/:shortterm').get(specialCentres.getByDeptSpecialCentres);
13+
14+
Router.route('/update/:term/:shortterm').patch(specialCentres.addFaculty);
15+
16+
17+
//Export----------------------------->
18+
module.exports = Router;

routes/studyprog.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const express = require("express");
2+
const studyProgramController = require("../controllers/study_programmes");
3+
//----------------------------------->
4+
5+
//Router
6+
const Router = express.Router();
7+
8+
Router.route("/").post(studyProgramController.addstudyProgrammes).get(studyProgramController.getAllstudyProgrammes);
9+
10+
Router.route("/:dept").get(studyProgramController.getByDeptstudyProgrammes).patch(studyProgramController.addstudyProgrammes).post(studyProgramController.deletestudyProgrammes);
11+
12+
Router.route("/get/all").get(studyProgramController.getAllstudyProgrammes);
13+
14+
//Export----------------------------->
15+
module.exports = Router;

t.js

-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,5 @@
4646
{
4747
"title": "Placeat veniam occaecati et qui accusantium.",
4848
"desc": "Placeat repudiandae quis omnis esse officiis quod. Quo non possimus distinctio nesciunt veritatis molestiae. Optio qui consequatur harum et est et eaque."
49-
5049
}
5150

0 commit comments

Comments
 (0)