From 298bab3150b46b7a8a054335cbf3f4e3818b9826 Mon Sep 17 00:00:00 2001 From: Rafael S Castliho <rsc15@inf.ufpr.br> Date: Tue, 23 Jul 2019 09:20:30 -0300 Subject: [PATCH] add youth_jobs --- src/libs/routes/SMPPIR/youth_jobs.js | 139 +++++++++++++++++++++++++++ src/libs/routes/api.js | 3 + 2 files changed, 142 insertions(+) create mode 100644 src/libs/routes/SMPPIR/youth_jobs.js diff --git a/src/libs/routes/SMPPIR/youth_jobs.js b/src/libs/routes/SMPPIR/youth_jobs.js new file mode 100644 index 00000000..a25b0797 --- /dev/null +++ b/src/libs/routes/SMPPIR/youth_jobs.js @@ -0,0 +1,139 @@ +/* +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_trabalho_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_trabalho_ag', + tableField: 'ano_censo', + resultField: 'ano_pesquisa', + where: { + relation: '=', + type: 'integer', + field: 'ano_censo', + }, +}) + +.addValue({ + name: 'cor_ raca', + table: 'jvt_trabalho_ag', + tableField: 'cor_raca', + resultField: 'cor_raca', + where: { + relation: '=', + type: 'integer', + field: 'cor_raca', + }, +}) + +.addValue({ + name: 'trabalhou', + table: 'jvt_trabalho_ag', + tableField: 'trabalhou_referencia', + resultField: 'trabalhou', + where: { + relation: '=', + type: 'integer', + field: 'trabalhou_referencia', + }, +}) + +.addValue({ + name: 'vinculo', + table: 'jvt_trabalho_ag', + tableField: 'tipo_vinculo', + resultField: 'vinculo', + where: { + relation: '=', + type: 'integer', + field: 'tipo_vinculo', + }, +}) + +.addValue({ + name: 'rendimento_faixa', + table: 'jvt_trabalho_ag', + tableField: 'rendimento_faixa', + resultField: 'rendimento_faixa', + where: { + relation: '=', + type: 'integer', + field: 'rendimento_faixa', + }, +}) + +.addValue({ + name: 'rendimento_bruto', + table: 'jvt_trabalho_ag', + tableField: 'rendimento_bruto', + resultField: 'rendimento_bruto', + where: { + relation: '=', + type: 'integer', + field: 'rendimento_bruto', + }, +}) + +.addValue({ + name: 'uf', + table: 'jvt_trabalho_ag', + tableField: 'sgl_uf', + resultField: 'uf', + where: { + relation: '=', + type: 'string', + field: 'uf', + }, +}) + +jvt_trabalho_ag.get('/', rqf.parse(), rqf.build(), (req, res, next) => { + console.log(req.sql.toString()); + req.sql.field('SUM(total) AS Total') + .from('jvt_trabalho_ag'); + next(); +}, query, response('jvt_trabalho_ag')); + +module.exports = jvt_trabalho_ag; diff --git a/src/libs/routes/api.js b/src/libs/routes/api.js index 630928f3..cf06b4d3 100644 --- a/src/libs/routes/api.js +++ b/src/libs/routes/api.js @@ -88,6 +88,8 @@ const ciganos_culture = require(`${libs}/routes/SMPPIR/ciganos_culture`) const ciganos_sustentability = require(`${libs}/routes/SMPPIR/ciganos_sustentability`) +const youth_jobs = require(`${libs}/routes/SMPPIR/youth_jobs`) + api.get('/', (req, res) => { res.json({ msg: 'SMPPIR API is running' }); @@ -125,6 +127,7 @@ api.use(`/quilombola_metrics`,quilombola_metrics) api.use('/ciganos_rights', ciganos_rights); api.use('/ciganos_culture', ciganos_culture); api.use('/ciganos_sustentability', ciganos_sustentability); +api.use('/youth_jobs', youth_jobs) module.exports = api; \ No newline at end of file -- GitLab