From 9e8a187c4e83477914a07dc1aa45e72978479f16 Mon Sep 17 00:00:00 2001
From: Pietro <ppc19@inf.ufpr.br>
Date: Wed, 23 Mar 2022 11:54:49 -0300
Subject: [PATCH] add subroutes

---
 src/libs/convert/enrollmentSituation.js | 33 +++++++++++++++++++++++
 src/libs/convert/enterSituation.js      | 35 +++++++++++++++++++++++++
 src/libs/middlewares/id2str.js          | 10 +++++--
 src/libs/routes/universityEnrollment.js | 24 +++++++++++++++++
 4 files changed, 100 insertions(+), 2 deletions(-)
 create mode 100644 src/libs/convert/enrollmentSituation.js
 create mode 100644 src/libs/convert/enterSituation.js

diff --git a/src/libs/convert/enrollmentSituation.js b/src/libs/convert/enrollmentSituation.js
new file mode 100644
index 00000000..9b709ea2
--- /dev/null
+++ b/src/libs/convert/enrollmentSituation.js
@@ -0,0 +1,33 @@
+/*
+Copyright (C) 2022 Centro de Computacao Cientifica e Software Livre
+Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
+
+This file is part of simcaq-node.
+
+simcaq-node is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+simcaq-node is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with simcaq-node.  If not, see <https://www.gnu.org/licenses/>.
+*/
+
+module.exports = function enrollmentSituation(id) {
+    switch (id) {
+        case 1:
+        return 'Ingressante';
+        case 2:
+        return 'Cursando';
+        case 3:
+        return 'Concluintes';
+        default:
+        return 'Não definido';
+    }
+};
+  
diff --git a/src/libs/convert/enterSituation.js b/src/libs/convert/enterSituation.js
new file mode 100644
index 00000000..1fe551d9
--- /dev/null
+++ b/src/libs/convert/enterSituation.js
@@ -0,0 +1,35 @@
+/*
+Copyright (C) 2022 Centro de Computacao Cientifica e Software Livre
+Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
+
+This file is part of simcaq-node.
+
+simcaq-node is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+simcaq-node is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with simcaq-node.  If not, see <https://www.gnu.org/licenses/>.
+*/
+
+module.exports = function enterSituation(id) {
+    switch (id) {
+        case 1:
+        return 'Cursando';
+        case 2:
+        return 'Concluinte';
+        case 3:
+        return 'Evadido';
+        case 4:
+        return 'Trancado';
+        default:
+        return 'Não definido';
+    }
+};
+  
diff --git a/src/libs/middlewares/id2str.js b/src/libs/middlewares/id2str.js
index fa6a20ca..668faa80 100644
--- a/src/libs/middlewares/id2str.js
+++ b/src/libs/middlewares/id2str.js
@@ -90,6 +90,8 @@ const initialTraining = require(`${libs}/convert/initialTraining`);
 const posTraining = require(`${libs}/convert/posTraining`);
 const licentiateDegree = require(`${libs}/convert/licentiateDegree`);
 const enrolledVacanciesFreshmen = require(`${libs}/convert/enrolledVacanciesFreshmen`);
+const enterSituation = require(`${libs}/convert/enterSituation`);
+const enrollmentSituation = require(`${libs}/convert/enrollmentSituation`);
 
 const ids = {
     gender_id: gender,
@@ -171,7 +173,9 @@ const ids = {
     initial_training_id: initialTraining,
     pos_training_id: posTraining,
     licentiate_degree_id: licentiateDegree,
-    enrolled_vacancies_freshmen: enrolledVacanciesFreshmen
+    enrolled_vacancies_freshmen: enrolledVacanciesFreshmen,
+    enter_situation: enterSituation,
+    enrollment_situation: enrollmentSituation
 };
 
 function transform(removeId=false) {
@@ -280,5 +284,7 @@ module.exports = {
     initialTraining,
     posTraining,
     licentiateDegree,
-    enrolledVacanciesFreshmen
+    enrolledVacanciesFreshmen,
+    enterSituation,
+    enrollmentSituation
 };
diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js
index 5adec697..d68166c3 100644
--- a/src/libs/routes/universityEnrollment.js
+++ b/src/libs/routes/universityEnrollment.js
@@ -286,6 +286,30 @@ universityEnrollmentApp.get('/age_student_code', function (req, res, next) {
     next();
 }, response('age_student_code'));
 
+
+universityEnrollmentApp.get('/student_enter_situation', function (req, res, next) {
+    req.result = [];
+    for (var i = 1; i <= 4; ++i) {
+        req.result.push({
+            id: i,
+            name: id2str.enterSituation(i)
+        });
+    };
+    next();
+}, response('student_enter_situation'));
+
+
+universityEnrollmentApp.get('/student_enrollment_situation', function (req, res, next) {
+    req.result = [];
+    for (var i = 1; i <= 3; ++i) {
+        req.result.push({
+            id: i,
+            name: id2str.enrollmentSituation(i)
+        });
+    };
+    next();
+}, response('student_enrollment_situation'));
+
 universityEnrollmentApp.get('/university', (req, res, next) => {
     req.sql.from('aluno_ens_superior')
     .field('DISTINCT aluno_ens_superior.nome_ies', 'nome')
-- 
GitLab