diff --git a/src/libs/routes/SMPPIR/quilombola_enrollment.js b/src/libs/routes/SMPPIR/quilombola_enrollment.js new file mode 100644 index 0000000000000000000000000000000000000000..a41bab05117ffbadc085b61c7ded7bd031579585 --- /dev/null +++ b/src/libs/routes/SMPPIR/quilombola_enrollment.js @@ -0,0 +1,145 @@ +'use strict'; + +/* +Copyright (C) 2019 Centro de Computacao Cientifica e Software Livre +Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + +This file is part of SMPPIR-Node. + +SMPPIR-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. + +SMPPIR-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 SMPPIR-Node. If not, see <https://www.gnu.org/licenses/>. +*/ + +var express = require('express'); + +var quilombolaEnrollmentApp = express.Router(); + +var libs = process.cwd() + '/libs'; + +var squel = require('squel'); + +var query = require(libs + '/middlewares/query').query; + +var response = require(libs + '/middlewares/response'); + +var ReqQueryFields = require(libs + '/middlewares/reqQueryFields'); + +var rqf = new ReqQueryFields(); + +rqf.addField({ + name: 'filter', + field: false, + where: true +}).addField({ + name: 'dims', + field: true, + where: false +}).addValue({ + name: 'year', + table: 'quilombola_schools_ag', + tableField: 'ano_censo', + resultField: 'ano_censo', + where: { + relation: '=', + type: 'integer', + field: 'ano_censo' + } +}).addValue({ + name: 'localizacao_diferenciada', + table: 'quilombola_schools_ag', + tableField: 'localizacao_diferenciada_id', + resultField: 'cod_localizacao_diferenciada', + where: { + relation: '=', + type: 'integer', + field: 'localizacao_diferenciada_id' + } +}).addValue({ + name: 'agua', + table: 'quilombola_schools_ag', + tableField: 'agua_rede_publica', + resultField: 'abastecimento_agua_rede_publica', + where: { + relation: '=', + type: 'string', + field: 'agua_rede_publica' + } +}).addValue({ + name: 'energia', + table: 'quilombola_schools_ag', + tableField: 'energia_rede_publica', + resultField: 'abastecimento_energia_rede_publica', + where: { + relation: '=', + type: 'string', + field: 'energia_rede_publica' + } +}).addValue({ + name: 'esgoto', + table: 'quilombola_schools_ag', + tableField: 'esgoto_rede_publica', + resultField: 'esgotamento_snaitario_rede_publica', + where: { + relation: '=', + type: 'string', + field: 'esgoto_rede_publica' + } +}).addValue({ + name: 'lixo', + table: 'quilombola_schools_ag', + tableField: 'lixo_coleta_periodica', + resultField: 'coleta_lixo_periodica', + where: { + relation: '=', + type: 'string', + field: 'lixo_coleta_periodica' + } +}).addValue({ + name: 'uf', + table: 'quilombola_schools_ag', + tableField: 'sigla', + resultField: 'sigla_uf', + where: { + relation: '=', + type: 'string', + field: 'sigla' + } +}).addValue({ + name: 'id', + table: 'quilombola_schools_ag', + tableField: 'id', + resultField: 'escola_id', + where: { + relation: '=', + type: 'string', + field: 'id' + } +}).addValue({ + name: 'etapa_ensino', + table: 'quilombola_schools_ag', + tableField: 'etapa_ensino', + resultField: 'etapa_ensino', + where: { + relation: '=', + type: 'string', + field: 'etapa_ensino' + } +}); + +quilombolaEnrollmentApp.get('/', rqf.parse(), rqf.build(), function (req, res, next) { + console.log(req.sql.toString()); + req.sql.field('SUM(total) AS Total').from('quilombola_schools_ag'); + next(); +}, query, response('quilombola_mat')); + +module.exports = quilombolaEnrollmentApp; \ No newline at end of file diff --git a/src/libs/routes/api.js b/src/libs/routes/api.js index 072c86132be050f689c469a09a31dfa1f848425a..47cdac5d08c2fbb866d6e2a83baf1796f0c74f17 100644 --- a/src/libs/routes/api.js +++ b/src/libs/routes/api.js @@ -130,6 +130,8 @@ const indigenas_enrollment = require(`${libs}/routes/SMPPIR/indigenas_enrollment const quilombola_schools = require(`${libs}/routes/SMPPIR/quilombola_schools`); +const quilombola_enrollment = require(`${libs}/routes/SMPPIR/indigenas_enrollment`); + api.get('/', (req, res) => { res.json({ msg: 'SMPPIR API is running' }); }); @@ -183,5 +185,6 @@ api.use('/indigenas_territorial', indigenas_territorial) api.use('/indigenas_schools', indigenas_schools) api.use('/indigenas_enrollment', indigenas_enrollment) api.use('/quilombola_schools', quilombola_schools) +api.use('/quilombola_enrollment', quilombola_enrollment) module.exports = api;