diff --git a/abitur_list_client/controllers/abitur.controllers.js b/abitur_list_client/controllers/abitur.controller.js similarity index 90% rename from abitur_list_client/controllers/abitur.controllers.js rename to abitur_list_client/controllers/abitur.controller.js index c5dc4d3..90351d8 100644 --- a/abitur_list_client/controllers/abitur.controllers.js +++ b/abitur_list_client/controllers/abitur.controller.js @@ -1,6 +1,6 @@ const db = require('../db') -const AbiturControllerInterface = require('../controllers/abitur.controller.interface') +const AbiturControllerInterface = require('./interfaces/abitur.controller.interface') class AbiturController extends AbiturControllerInterface{ async createAbitur(req, res) { diff --git a/abitur_list_client/controllers/educationform.controller.js b/abitur_list_client/controllers/educationform.controller.js new file mode 100644 index 0000000..9e477cf --- /dev/null +++ b/abitur_list_client/controllers/educationform.controller.js @@ -0,0 +1,32 @@ +const db = require('../db') + +const EducationFormControllerInterface = require('./interfaces/educationform.controller.interface') + +class EducationFormController extends EducationFormControllerInterface { + async createEducationForm(req, res) { + const {title} = req.body + const newEducationForm = await db.query('INSERT INTO education_form (title) VALUES ($1) RETURNING *', [title]) + res.json(newEducationForm.rows[0]) + } + async getEducationForms(req, res) { + const forms = await db.query('SELECT * FROM education_form') + res.json(forms.rows) + } + async getOneEducationForm(req, res) { + const id = req.params.id + const forms = await db.query('SELECT * FROM education_form WHERE id=$1', [id]) + res.json(forms.rows[0]) + } + async updateEducationForm(req, res) { + const {id, title} = req.body + const newEducationForm = await db.query('UPDATE education_form SET title=$1 WHERE id=$2 RETURNING *', [title, id]) + res.json(newEducationForm.rows[0]) + } + async deleteEducationForm(req, res) { + const id = req.params.id + const forms = await db.query('DELETE FROM education_form WHERE id=$1', [id]) + res.json(forms.rows[0]) + } +} + +module.exports = new EducationFormController() \ No newline at end of file diff --git a/abitur_list_client/controllers/enrollment.controller.js b/abitur_list_client/controllers/enrollment.controller.js new file mode 100644 index 0000000..137b573 --- /dev/null +++ b/abitur_list_client/controllers/enrollment.controller.js @@ -0,0 +1,32 @@ +const db = require('../db') + +const EnrollmentControllerInterface = require('./interfaces/enrollment.controller.interface') + +class EnrollmentController extends EnrollmentControllerInterface { + async createEnrollment(req, res) { + const {request_id} = req.body + const newEnrollment = await db.query('INSERT INTO enrollment (request_id, date) VALUES ($1, $2) RETURNING *', [request_id, new Date()]) + res.json(newEnrollment.rows[0]) + } + async getEnrollments(req, res) { + const enrollments = await db.query('SELECT * FROM enrollment') + res.json(enrollments.rows) + } + async getOneEnrollment(req, res) { + const id = req.params.id + const enrollments = await db.query('SELECT * FROM enrollment WHERE id=$1', [id]) + res.json(enrollments.rows[0]) + } + async updateEnrollment(req, res) { + const {id, request_id, date} = req.body + const newEnrollment = await db.query('UPDATE enrollment SET request_id=$1, date=$2 WHERE id=$3 RETURNING *', [request_id, date, id]) + res.json(newEnrollment.rows[0]) + } + async deleteEnrollment(req, res) { + const id = req.params.id + const enrollments = await db.query('DELETE FROM enrollment WHERE id=$1', [id]) + res.json(enrollments.rows[0]) + } +} + +module.exports = new EnrollmentController() \ No newline at end of file diff --git a/abitur_list_client/controllers/examresult.controller.js b/abitur_list_client/controllers/examresult.controller.js new file mode 100644 index 0000000..97cba9b --- /dev/null +++ b/abitur_list_client/controllers/examresult.controller.js @@ -0,0 +1,32 @@ +const db = require('../db') + +const ExamResultControllerInterface = require('./interfaces/examresult.controller.interface') + +class ExamResultController extends ExamResultControllerInterface { + async createExamResult(req, res) { + const {title, result, abitur_id} = req.body + const newExamResult = await db.query('INSERT INTO exam_result (title, result, abitur_id) VALUES ($1, $2, $3) RETURNING *', [title, result, abitur_id]) + res.json(newExamResult.rows[0]) + } + async getExamResults(req, res) { + const results = await db.query('SELECT * FROM exam_result') + res.json(results.rows) + } + async getOneExamResult(req, res) { + const id = req.params.id + const results = await db.query('SELECT * FROM exam_result WHERE id=$1', [id]) + res.json(results.rows[0]) + } + async updateExamResult(req, res) { + const {id, title, result} = req.body + const newExamResult = await db.query('UPDATE exam_result SET title=$1, result=$2 WHERE id=$3 RETURNING *', [title, result, id]) + res.json(newExamResult.rows[0]) + } + async deleteExamResult(req, res) { + const id = req.params.id + const results = await db.query('DELETE FROM exam_result WHERE id=$1', [id]) + res.json(results.rows[0]) + } +} + +module.exports = new ExamResultController() \ No newline at end of file diff --git a/abitur_list_client/controllers/abitur.controller.interface.js b/abitur_list_client/controllers/interfaces/abitur.controller.interface.js similarity index 99% rename from abitur_list_client/controllers/abitur.controller.interface.js rename to abitur_list_client/controllers/interfaces/abitur.controller.interface.js index bae56dc..59e91ee 100644 --- a/abitur_list_client/controllers/abitur.controller.interface.js +++ b/abitur_list_client/controllers/interfaces/abitur.controller.interface.js @@ -8,6 +8,5 @@ module.exports = class AbiturControllerInterface { async updateAbitur(req, res) { } async deleteAbitur(req, res) { - } } \ No newline at end of file diff --git a/abitur_list_client/controllers/interfaces/educationform.controller.interface.js b/abitur_list_client/controllers/interfaces/educationform.controller.interface.js new file mode 100644 index 0000000..5a67857 --- /dev/null +++ b/abitur_list_client/controllers/interfaces/educationform.controller.interface.js @@ -0,0 +1,12 @@ +module.exports = class EducationFormControllerInterface { + async createEducationForm(req, res) { + } + async getEducationForms(req, res) { + } + async getOneEducationForm(req, res) { + } + async updateEducationForm(req, res) { + } + async deleteEducationForm(req, res) { + } +} \ No newline at end of file diff --git a/abitur_list_client/controllers/interfaces/enrollment.controller.interface.js b/abitur_list_client/controllers/interfaces/enrollment.controller.interface.js new file mode 100644 index 0000000..67731c3 --- /dev/null +++ b/abitur_list_client/controllers/interfaces/enrollment.controller.interface.js @@ -0,0 +1,12 @@ +module.exports = class EnrollmentControllerInterface { + async createEnrollment(req, res) { + } + async getEnrollments(req, res) { + } + async getOneEnrollment(req, res) { + } + async updateEnrollment(req, res) { + } + async deleteEnrollment(req, res) { + } +} \ No newline at end of file diff --git a/abitur_list_client/controllers/interfaces/examresult.controller.interface.js b/abitur_list_client/controllers/interfaces/examresult.controller.interface.js new file mode 100644 index 0000000..72f5718 --- /dev/null +++ b/abitur_list_client/controllers/interfaces/examresult.controller.interface.js @@ -0,0 +1,12 @@ +module.exports = class ExamResultControllerInterface { + async createExamResult(req, res) { + } + async getExamResults(req, res) { + } + async getOneExamResult(req, res) { + } + async updateExamResult(req, res) { + } + async deleteExamResult(req, res) { + } +} \ No newline at end of file diff --git a/abitur_list_client/controllers/interfaces/request.controller.interface.js b/abitur_list_client/controllers/interfaces/request.controller.interface.js new file mode 100644 index 0000000..91b6de7 --- /dev/null +++ b/abitur_list_client/controllers/interfaces/request.controller.interface.js @@ -0,0 +1,12 @@ +module.exports = class RequestControllerInterface { + async createRequest(req, res) { + } + async getRequests(req, res) { + } + async getOneRequest(req, res) { + } + async updateRequest(req, res) { + } + async deleteRequest(req, res) { + } +} \ No newline at end of file diff --git a/abitur_list_client/controllers/interfaces/request_examresult.controller.interface.js b/abitur_list_client/controllers/interfaces/request_examresult.controller.interface.js new file mode 100644 index 0000000..4838467 --- /dev/null +++ b/abitur_list_client/controllers/interfaces/request_examresult.controller.interface.js @@ -0,0 +1,8 @@ +module.exports = class Request_ExamResultControllerInterface { + async createRecord(req, res) { + } + async getRecords(req, res) { + } + async deleteRecord(req, res) { + } +} \ No newline at end of file diff --git a/abitur_list_client/controllers/interfaces/specialization.controller.interface.js b/abitur_list_client/controllers/interfaces/specialization.controller.interface.js new file mode 100644 index 0000000..565b306 --- /dev/null +++ b/abitur_list_client/controllers/interfaces/specialization.controller.interface.js @@ -0,0 +1,12 @@ +module.exports = class SpecializationControllerInterface { + async createSpecialization(req, res) { + } + async getSpecializations(req, res) { + } + async getOneSpecialization(req, res) { + } + async updateSpecialization(req, res) { + } + async deleteSpecialization(req, res) { + } +} \ No newline at end of file diff --git a/abitur_list_client/controllers/request.controller.js b/abitur_list_client/controllers/request.controller.js new file mode 100644 index 0000000..c93621a --- /dev/null +++ b/abitur_list_client/controllers/request.controller.js @@ -0,0 +1,32 @@ +const db = require('../db') + +const RequestControllerInterface = require('./interfaces/request.controller.interface') + +class RequestController extends RequestControllerInterface { + async createRequest(req, res) { + const {abitur_id, education_form_id, specialization_id} = req.body + const newRequest = await db.query('INSERT INTO request (abitur_id, education_form_id, specialization_id, date) VALUES ($1, $2, $3, $4) RETURNING *', [abitur_id, education_form_id, specialization_id, new Date()]) + res.json(newRequest.rows[0]) + } + async getRequests(req, res) { + const requests = await db.query('SELECT * FROM request') + res.json(requests.rows) + } + async getOneRequest(req, res) { + const id = req.params.id + const requests = await db.query('SELECT * FROM request WHERE id=$1', [id]) + res.json(requests.rows[0]) + } + async updateRequest(req, res) { + const {id, education_form_id, specialization_id, date} = req.body + const newRequest = await db.query('UPDATE request SET education_form_id=$1, specialization_id=$2, date=$3 WHERE id=$4 RETURNING *', [education_form_id, specialization_id, date, id]) + res.json(newRequest.rows[0]) + } + async deleteRequest(req, res) { + const id = req.params.id + const requests = await db.query('DELETE FROM request WHERE id=$1', [id]) + res.json(requests.rows[0]) + } +} + +module.exports = new RequestController() \ No newline at end of file diff --git a/abitur_list_client/controllers/request_examresult.controller.js b/abitur_list_client/controllers/request_examresult.controller.js new file mode 100644 index 0000000..66a2c2a --- /dev/null +++ b/abitur_list_client/controllers/request_examresult.controller.js @@ -0,0 +1,23 @@ +const db = require('../db') + +const Request_ExamResultControllerInterface = require('./interfaces/request_examresult.controller.interface') + +class Request_ExamResultController extends Request_ExamResultControllerInterface { + async createRecord(req, res) { + const {request_id, exam_result_id} = req.body + const newRecord = await db.query('INSERT INTO request_exam_result (request_id, exam_result_id) VALUES ($1, $2) RETURNING *', [request_id, exam_result_id]) + res.json(newRecord.rows[0]) + } + async getRecords(req, res) { + const id = req.params.id + const records = await db.query('SELECT * FROM request_exam_result WHERE request_id=$1', [id]) + res.json(records.rows) + } + async deleteRecord(req, res) { + const {request_id, exam_result_id} = req.body + const records = await db.query('DELETE FROM request_exam_result WHERE request_id=$1 AND exam_result_id=$2', [request_id, exam_result_id]) + res.json(records.rows[0]) + } +} + +module.exports = new Request_ExamResultController() \ No newline at end of file diff --git a/abitur_list_client/controllers/specialization.controller.js b/abitur_list_client/controllers/specialization.controller.js new file mode 100644 index 0000000..8386686 --- /dev/null +++ b/abitur_list_client/controllers/specialization.controller.js @@ -0,0 +1,32 @@ +const db = require('../db') + +const SpecializationControllerInterface = require('./interfaces/specialization.controller.interface') + +class SpecializationController extends SpecializationControllerInterface { + async createSpecialization(req, res) { + const {title} = req.body + const newSpecialization = await db.query('INSERT INTO specialization (title) VALUES ($1) RETURNING *', [title]) + res.json(newSpecialization.rows[0]) + } + async getSpecializations(req, res) { + const specializations = await db.query('SELECT * FROM specialization') + res.json(specializations.rows) + } + async getOneSpecialization(req, res) { + const id = req.params.id + const specializations = await db.query('SELECT * FROM specialization WHERE id=$1', [id]) + res.json(specializations.rows[0]) + } + async updateSpecialization(req, res) { + const {id, title} = req.body + const newSpecialization = await db.query('UPDATE specialization SET title=$1 WHERE id=$2 RETURNING *', [title, id]) + res.json(newSpecialization.rows[0]) + } + async deleteSpecialization(req, res) { + const id = req.params.id + const specializations = await db.query('DELETE FROM specialization WHERE id=$1', [id]) + res.json(specializations.rows[0]) + } +} + +module.exports = new SpecializationController() \ No newline at end of file diff --git a/abitur_list_client/index.js b/abitur_list_client/index.js index cf9de14..635083e 100644 --- a/abitur_list_client/index.js +++ b/abitur_list_client/index.js @@ -1,6 +1,12 @@ const express = require('express') const abiturRouter = require('./routes/abitur.routes') +const examResultRouter = require('./routes/examresult.routes') +const specializationRouter = require('./routes/specialization.routes') +const educationFormRouter = require('./routes/educationform.routes') +const requestRouter = require('./routes/request.routes') +const request_examresultRouter = require('./routes/request_examresult.routes') +const enrollmentRouter = require('./routes/enrollment.routes') const PORT = process.env.PORT || 8080 @@ -8,5 +14,12 @@ const app = express() app.use(express.json()) app.use('/api', abiturRouter) +app.use('/api', examResultRouter) +app.use('/api', specializationRouter) +app.use('/api', educationFormRouter) +app.use('/api', requestRouter) +app.use('/api', request_examresultRouter) +app.use('/api', enrollmentRouter) + app.listen(PORT, () => console.log('server started on port ' + PORT)) \ No newline at end of file diff --git a/abitur_list_client/routes/abitur.routes.js b/abitur_list_client/routes/abitur.routes.js index 7b495ca..1788d82 100644 --- a/abitur_list_client/routes/abitur.routes.js +++ b/abitur_list_client/routes/abitur.routes.js @@ -1,7 +1,7 @@ const Router = require('express') const router = new Router() -const abiturController = require('../controllers/abitur.controllers') +const abiturController = require('../controllers/abitur.controller') router.post('/abitur', abiturController.createAbitur) router.get('/abitur', abiturController.getAbiturs) diff --git a/abitur_list_client/routes/educationform.routes.js b/abitur_list_client/routes/educationform.routes.js new file mode 100644 index 0000000..611f77c --- /dev/null +++ b/abitur_list_client/routes/educationform.routes.js @@ -0,0 +1,12 @@ +const Router = require('express') +const router = new Router() + +const educationformController = require('../controllers/educationform.controller') + +router.post('/educationform', educationformController.createEducationForm) +router.get('/educationform', educationformController.getEducationForms) +router.get('/educationform/:id', educationformController.getOneEducationForm) +router.put('/educationform', educationformController.updateEducationForm) +router.delete('/educationform/:id', educationformController.deleteEducationForm) + +module.exports = router \ No newline at end of file diff --git a/abitur_list_client/routes/enrollment.routes.js b/abitur_list_client/routes/enrollment.routes.js new file mode 100644 index 0000000..cd39154 --- /dev/null +++ b/abitur_list_client/routes/enrollment.routes.js @@ -0,0 +1,12 @@ +const Router = require('express') +const router = new Router() + +const enrollmentController = require('../controllers/enrollment.controller') + +router.post('/enrollment', enrollmentController.createEnrollment) +router.get('/enrollment', enrollmentController.getEnrollments) +router.get('/enrollment/:id', enrollmentController.getOneEnrollment) +router.put('/enrollment', enrollmentController.updateEnrollment) +router.delete('/enrollment/:id', enrollmentController.deleteEnrollment) + +module.exports = router \ No newline at end of file diff --git a/abitur_list_client/routes/examresult.routes.js b/abitur_list_client/routes/examresult.routes.js new file mode 100644 index 0000000..ef6fe95 --- /dev/null +++ b/abitur_list_client/routes/examresult.routes.js @@ -0,0 +1,12 @@ +const Router = require('express') +const router = new Router() + +const examResultController = require('../controllers/examresult.controller') + +router.post('/examresult', examResultController.createExamResult) +router.get('/examresult', examResultController.getExamResults) +router.get('/examresult/:id', examResultController.getOneExamResult) +router.put('/examresult', examResultController.updateExamResult) +router.delete('/examresult/:id', examResultController.deleteExamResult) + +module.exports = router \ No newline at end of file diff --git a/abitur_list_client/routes/request.routes.js b/abitur_list_client/routes/request.routes.js new file mode 100644 index 0000000..a11f8c4 --- /dev/null +++ b/abitur_list_client/routes/request.routes.js @@ -0,0 +1,12 @@ +const Router = require('express') +const router = new Router() + +const requestController = require('../controllers/request.controller') + +router.post('/request', requestController.createRequest) +router.get('/request', requestController.getRequests) +router.get('/request/:id', requestController.getRequests) +router.put('/request', requestController.updateRequest) +router.delete('/request/:id', requestController.deleteRequest) + +module.exports = router \ No newline at end of file diff --git a/abitur_list_client/routes/request_examresult.routes.js b/abitur_list_client/routes/request_examresult.routes.js new file mode 100644 index 0000000..b0dccc9 --- /dev/null +++ b/abitur_list_client/routes/request_examresult.routes.js @@ -0,0 +1,10 @@ +const Router = require('express') +const router = new Router() + +const request_examresultController = require('../controllers/request_examresult.controller') + +router.post('/request_examresult', request_examresultController.createRecord) +router.get('/request_examresult/:id', request_examresultController.getRecords) +router.delete('/request_examresult', request_examresultController.deleteRecord) + +module.exports = router \ No newline at end of file diff --git a/abitur_list_client/routes/specialization.routes.js b/abitur_list_client/routes/specialization.routes.js new file mode 100644 index 0000000..bda016a --- /dev/null +++ b/abitur_list_client/routes/specialization.routes.js @@ -0,0 +1,12 @@ +const Router = require('express') +const router = new Router() + +const specializationController = require('../controllers/specialization.controller') + +router.post('/specialization', specializationController.createSpecialization) +router.get('/specialization', specializationController.getSpecializations) +router.get('/specialization/:id', specializationController.getOneSpecialization) +router.put('/specialization', specializationController.updateSpecialization) +router.delete('/specialization/:id', specializationController.deleteSpecialization) + +module.exports = router \ No newline at end of file