diff --git a/src/libs/routes/SMPPIR/youth_education.js b/src/libs/routes/SMPPIR/youth_education.js new file mode 100644 index 0000000000000000000000000000000000000000..5e00b5278bedd4b749158379baae67b1e453f8d3 --- /dev/null +++ b/src/libs/routes/SMPPIR/youth_education.js @@ -0,0 +1,164 @@ +/* +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/>. +*/ + + + +const express = require('express'); + +const jvt_educacao_ag = express.Router(); + +const libs = `${process.cwd()}/libs`; + +const squel = require('squel'); + +const query = require(`${libs}/middlewares/query`).query; + +const response = require(`${libs}/middlewares/response`); + +const ReqQueryFields = require(`${libs}/middlewares/reqQueryFields`); + +const rqf = new ReqQueryFields(); + +rqf.addField({ + name: 'filter', + field: false, + where: true, +}).addField({ + name: 'dims', + field: true, + where: false, +}) +.addValue({ + name: 'year', + table: 'jvt_educacao_ag', + tableField: 'ano_censo', + resultField: 'ano_pesquisa', + where: { + relation: '=', + type: 'integer', + field: 'ano_censo', + }, +}) + +.addValue({ + name: 'cor_raca', + table: 'jvt_educacao_ag', + tableField: 'cor_raca', + resultField: 'cor_raca', + where: { + relation: '=', + type: 'integer', + field: 'cor_raca', + }, +}) + +.addValue({ + name: 'age', + table: 'jvt_educacao_ag', + tableField: 'idade', + resultField: 'age', + where: { + relation: '=', + type: 'integer', + field: 'idade', + }, +}) + +.addValue({ + name: 'max_level', + table: 'jvt_educacao_ag', + tableField: 'maior_nivel', + resultField: 'max_level', + where: { + relation: '=', + type: 'integer', + field: 'maior_nivel', + }, +}) + +.addValue({ + name: 'concluiu', + table: 'jvt_educacao_ag', + tableField: 'concluiu_frequentou', + resultField: 'concluiu', + where: { + relation: '=', + type: 'integer', + field: 'concluiu_frequentou', + }, +}) + +.addValue({ + name: 'in_escola', + table: 'jvt_educacao_ag', + tableField: 'in_escola', + resultField: 'in_escola', + where: { + relation: '=', + type: 'integer', + field: 'in_escola', + }, +}) + +.addValue({ + name: 'frequenta', + table: 'jvt_educacao_ag', + tableField: 'serie_frequenta', + resultField: 'frequenta', + where: { + relation: '=', + type: 'integer', + field: 'serie_frequenta', + }, +}) + +.addValue({ + name: 'nivel_escola', + table: 'jvt_educacao_ag', + tableField: 'nivel_escola', + resultField: 'nivel_escola', + where: { + relation: '=', + type: 'integer', + field: 'nivel_escola', + }, +}) + + +.addValue({ + name: 'uf', + table: 'jvt_educacao_ag', + tableField: 'sgl_uf', + resultField: 'uf', + where: { + relation: '=', + type: 'string', + field: 'uf', + }, +}) + +jvt_educacao_ag.get('/', rqf.parse(), rqf.build(), (req, res, next) => { + console.log(req.sql.toString()); + req.sql.field('SUM(total) AS Total') + .from('jvt_educacao_ag'); + next(); +}, query, response('jvt_educacao_ag')); + +module.exports = jvt_educacao_ag; diff --git a/src/libs/routes/SMPPIR/youth_jobs.js b/src/libs/routes/SMPPIR/youth_jobs.js index a25b0797309937291d012ef73aee8eb63f917429..e4281870d232a7313f00696941d0c2e0d2486b6e 100644 --- a/src/libs/routes/SMPPIR/youth_jobs.js +++ b/src/libs/routes/SMPPIR/youth_jobs.js @@ -58,7 +58,7 @@ rqf.addField({ }) .addValue({ - name: 'cor_ raca', + name: 'cor_raca', table: 'jvt_trabalho_ag', tableField: 'cor_raca', resultField: 'cor_raca', diff --git a/src/libs/routes/api.js b/src/libs/routes/api.js index cf06b4d301dea0dd806ee95e893cd9858ba6255a..abc8a2d74133a2abf4bac63f47e0e5fdf7bbbbc1 100644 --- a/src/libs/routes/api.js +++ b/src/libs/routes/api.js @@ -90,6 +90,8 @@ const ciganos_sustentability = require(`${libs}/routes/SMPPIR/ciganos_sustentabi const youth_jobs = require(`${libs}/routes/SMPPIR/youth_jobs`) +const youth_education = require(`${libs}/routes/SMPPIR/youth_education`) + api.get('/', (req, res) => { res.json({ msg: 'SMPPIR API is running' }); @@ -128,6 +130,6 @@ api.use('/ciganos_rights', ciganos_rights); api.use('/ciganos_culture', ciganos_culture); api.use('/ciganos_sustentability', ciganos_sustentability); api.use('/youth_jobs', youth_jobs) - +api.use('/youth_education', youth_education) module.exports = api; \ No newline at end of file