From e0ebfbe9ddb627f86ec0624038d1b94abf6b928e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20Pedro=20Picolo?= <jpp18@inf.ufpr.br>
Date: Tue, 10 Nov 2020 09:42:35 -0300
Subject: [PATCH] Adds licentiate degree route

---
 src/libs/convert/licentiateDegree.js | 30 ++++++++++++++++++++++++++++
 src/libs/middlewares/id2str.js       |  4 +++-
 src/libs/routes/teacher.js           | 21 +++++++++++++++++++
 3 files changed, 54 insertions(+), 1 deletion(-)
 create mode 100644 src/libs/convert/licentiateDegree.js

diff --git a/src/libs/convert/licentiateDegree.js b/src/libs/convert/licentiateDegree.js
new file mode 100644
index 00000000..cc103374
--- /dev/null
+++ b/src/libs/convert/licentiateDegree.js
@@ -0,0 +1,30 @@
+/*
+Copyright (C) 2016 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 licentiateDegree(id) {
+    switch (id) {
+    case 1:
+        return 'Sem ensino superior';
+    case 2:
+        return 'Superior com bacharelado ou tecnólogo';
+    case 3:
+        return 'Superior com licenciatura ou complementação pedagógica';
+    }
+};
diff --git a/src/libs/middlewares/id2str.js b/src/libs/middlewares/id2str.js
index cb9a18d6..a75d1531 100644
--- a/src/libs/middlewares/id2str.js
+++ b/src/libs/middlewares/id2str.js
@@ -88,6 +88,7 @@ const discipline = require(`${libs}/convert/discipline`);
 const finishUniversity = require(`${libs}/convert/finishUniversity`);
 const initialTraining = require(`${libs}/convert/initialTraining`);
 const posTraining = require(`${libs}/convert/posTraining`);
+const licentiateDegree = require(`${libs}/convert/licentiateDegree`);
 
 const ids = {
     gender_id: gender,
@@ -167,7 +168,8 @@ const ids = {
     discipline: discipline,
     finish_id: finishUniversity,
     initial_training_id: initialTraining,
-    pos_training_id: posTraining
+    pos_training_id: posTraining,
+    licentiate_degree_id: licentiateDegree
 };
 
 function transform(removeId=false) {
diff --git a/src/libs/routes/teacher.js b/src/libs/routes/teacher.js
index b2a4dc4e..80a1a905 100644
--- a/src/libs/routes/teacher.js
+++ b/src/libs/routes/teacher.js
@@ -204,6 +204,17 @@ teacherApp.get('/pos_training', (req, res, next) => {
   next();
 }, response('pos_training'));
 
+teacherApp.get('/licentiate_degree', (req, res, next) => {
+    req.result = [];
+    for(let i = 1; i <= 3; ++i) {
+        req.result.push({
+            id: i,
+            name: id2str.licentiateDegree(i)
+        });
+  }
+  next();
+}, response('licentiate_degree'));
+
 rqf.addField({
     name: 'filter',
     field: false,
@@ -474,6 +485,16 @@ rqf.addField({
         type: 'integer',
         field: 'formacao_pos_docente'
     }
+}).addValue({
+    name: 'licentiate_degree',
+    table: 'docente',
+    tableField: 'formacao_licenciatura_docente',
+    resultField: 'licentiate_degree_id',
+    where: {
+        relation: '=',
+        type: 'integer',
+        field: 'formacao_licenciatura_docente'
+    }
 });
 
 teacherApp.get('/', rqf.parse(), (req, res, next) => {
-- 
GitLab