diff --git a/src/libs/routes/SMPPIR/indigenas_development.js b/src/libs/routes/SMPPIR/indigenas_development.js new file mode 100644 index 0000000000000000000000000000000000000000..4486c8f5b74aa35bc9a2fdd9104fc4b9aa46a690 --- /dev/null +++ b/src/libs/routes/SMPPIR/indigenas_development.js @@ -0,0 +1,135 @@ +'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 cad_unico_count = 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: 'indigenas_development_ag', + tableField: 'ano_censo', + resultField: 'ano_pesquisa', + where: { + relation: '=', + type: 'integer', + field: 'ano_censo' + } +}).addValue({ + name: 'family_type', + table: 'indigenas_development_ag', + tableField: 'ind_tipo_familia', + resultField: 'ind_parc_mds_fam', + where: { + relation: '=', + type: 'string', + field: 'ind_tipo_familia' + } +}).addValue({ + name: 'cod_home_bolsa_familia', + table: 'indigenas_development_ag', + tableField: 'marca_programa_bolsa_familia', + resultField: 'marc_pbf', + where: { + relation: '=', + type: 'string', + field: 'marca_programa_bolsa_familia' + } +}).addValue({ + name: 'cod_agriculture_job', + table: 'indigenas_development_ag', + tableField: 'atividade_extrativista', + resultField: 'cod_agricultura_trab_memb', + where: { + relation: '=', + type: 'string', + field: 'atividade_extrativista' + } +}).addValue({ + name: 'per_capita_income', + table: 'indigenas_development_ag', + tableField: 'renda_media', + resultField: 'vlr_renda_media_fam', + where: { + relation: '=', + type: 'float', + field: 'renda_media' + } +}).addValue({ + name: 'home_location', + table: 'indigenas_development_ag', + tableField: 'codigo_ibge', + resultField: 'cd_ibge', + where: { + relation: '=', + type: 'string', + field: 'codigo_ibge' + } +}).addValue({ + name: 'uf', + table: 'indigenas_development_ag', + tableField: 'sigla_estado', + resultField: 'uf', + where: { + relation: '=', + type: 'string', + field: 'sigla_estado' + } +}).addValue({ + name: 'region', + table: 'indigenas_development_ag', + tableField: 'nome_regiao', + resultField: 'region', + where: { + relation: '=', + type: 'string', + field: 'nome_regiao' + } +}); + +cad_unico_count.get('/', rqf.parse(), rqf.build(), function (req, res, next) { + console.log(req.sql.toString()); + req.sql.field('SUM(total) AS Total').from('indigenas_development_ag'); + next(); +}, query, response('cad_unico')); + +module.exports = cad_unico_count; \ No newline at end of file diff --git a/src/libs/routes/SMPPIR/indigenas_infrastructure.js b/src/libs/routes/SMPPIR/indigenas_infrastructure.js new file mode 100644 index 0000000000000000000000000000000000000000..470d436663e1e1bb088517d9ed7bc82563821e74 --- /dev/null +++ b/src/libs/routes/SMPPIR/indigenas_infrastructure.js @@ -0,0 +1,155 @@ +'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 cad_unico = 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: 'indigenas_infrastructure_ag', + tableField: 'ano_censo', + resultField: 'ano_pesquisa', + where: { + relation: '=', + type: 'integer', + field: 'ano_censo' + } +}).addValue({ + name: 'family_type', + table: 'indigenas_infrastructure_ag', + tableField: 'ind_tipo_familia', + resultField: 'ind_parc_mds_fam', + where: { + relation: '=', + type: 'string', + field: 'ind_tipo_familia' + } +}).addValue({ + name: 'cod_local_home', + table: 'indigenas_infrastructure_ag', + tableField: 'cod_local_domicilio', + resultField: 'cod_local_domic_fam', + where: { + relation: '=', + type: 'string', + field: 'cod_local_domicilio' + } +}).addValue({ + name: 'cod_home_lighting', + table: 'indigenas_infrastructure_ag', + tableField: 'cod_iluminacao_domicilio', + resultField: 'cod_iluminacao_domic_fam', + where: { + relation: '=', + type: 'string', + field: 'cod_iluminacao_domicilio' + } +}).addValue({ + name: 'cod_home_trash_destiny', + table: 'indigenas_infrastructure_ag', + tableField: 'cod_destino_lixo_domicilio', + resultField: 'cod_destino_lixo_domic_fam', + where: { + relation: '=', + type: 'string', + field: 'cod_destino_lixo_domicilio' + } +}).addValue({ + name: 'cod_home_watter_supply', + table: 'indigenas_infrastructure_ag', + tableField: 'cod_abastecimento_agua_domicilio', + resultField: 'cod_abaste_agua_domic_fam', + where: { + relation: '=', + type: 'string', + field: 'cod_abastecimento_agua_domicilio' + } +}).addValue({ + name: 'home_type', + table: 'indigenas_infrastructure_ag', + tableField: 'cod_especie_domicilio', + resultField: 'cod_especie_domic_fam', + where: { + relation: '=', + type: 'string', + field: 'cod_especie_domicilio' + } +}).addValue({ + name: 'uf', + table: 'indigenas_infrastructure_ag', + tableField: 'sigla_estado', + resultField: 'uf', + where: { + relation: '=', + type: 'string', + field: 'sigla_estado' + } +}).addValue({ + name: 'region', + table: 'indigenas_infrastructure_ag', + tableField: 'nome_regiao', + resultField: 'region', + where: { + relation: '=', + type: 'string', + field: 'nome_regiao' + } +}).addValue({ + name: 'cod_sanitary_dump', + table: 'indigenas_infrastructure_ag', + tableField: 'cod_escoa_sanitario_domicilio', + resultField: 'cod_escoa_sanitario_domic_fam', + where: { + relation: '=', + type: 'string', + field: 'cod_escoa_sanitario_domic_fam' + } +}); + +cad_unico.get('/', rqf.parse(), rqf.build(), function (req, res, next) { + console.log(req.sql.toString()); + req.sql.field('SUM(total) AS Total').from('indigenas_infrastructure_ag'); + next(); +}, query, response('cad_unico')); + +module.exports = cad_unico; \ No newline at end of file diff --git a/src/libs/routes/SMPPIR/indigenas_rights.js b/src/libs/routes/SMPPIR/indigenas_rights.js new file mode 100644 index 0000000000000000000000000000000000000000..478b05f48b16bab3315ec80ef4d0b1ed08bbd19b --- /dev/null +++ b/src/libs/routes/SMPPIR/indigenas_rights.js @@ -0,0 +1,135 @@ +'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 cad_unico = 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: 'indigenas_rights_ag', + tableField: 'ano_censo', + resultField: 'ano_pesquisa', + where: { + relation: '=', + type: 'integer', + field: 'ano_censo' + } +}).addValue({ + name: 'age', + table: 'indigenas_rights_ag', + tableField: 'idade', + resultField: 'idade', + where: { + relation: '=', + type: 'string', + field: 'idade' + } +}).addValue({ + name: 'education_families_conclude', + table: 'indigenas_rights_ag', + tableField: 'concluiu_frequentou', + resultField: 'cod_concluiu_frequentou_memb', + where: { + relation: '=', + type: 'string', + field: 'concluiu_frequentou' + } +}).addValue({ + name: 'education_families_level', + table: 'indigenas_rights_ag', + tableField: 'ano_serie_frequentou', + resultField: 'cod_ano_serie_frequentou_memb', + where: { + relation: '=', + type: 'string', + field: 'ano_serie_frequentou' + } +}).addValue({ + name: 'education_families', + table: 'indigenas_rights_ag', + tableField: 'curso_frequentou', + resultField: 'cod_curso_frequentou_pessoa_memb', + where: { + relation: '=', + type: 'string', + field: 'curso_frequentou' + } +}).addValue({ + name: 'uf', + table: 'indigenas_rights_ag', + tableField: 'sigla_estado', + resultField: 'uf', + where: { + relation: '=', + type: 'string', + field: 'sigla_estado' + } +}).addValue({ + name: 'region', + table: 'indigenas_rights_ag', + tableField: 'nome_regiao', + resultField: 'region', + where: { + relation: '=', + type: 'string', + field: 'nome_regiao' + } +}).addValue({ + name: 'gender', + table: 'indigenas_rights_ag', + tableField: 'genero', + resultField: 'genero', + where: { + relation: '=', + type: 'string', + field: 'genero' + } +}); + +cad_unico.get('/', rqf.parse(), rqf.build(), function (req, res, next) { + console.log(req.sql.toString()); + req.sql.field('SUM(total) AS Total').from('indigenas_rights_ag'); + next(); +}, query, response('cad_unico')); + +module.exports = cad_unico; \ No newline at end of file diff --git a/src/libs/routes/api.js b/src/libs/routes/api.js index 23c1b92d4ff5cdeac4fd1ef71fd052f820a4c6e8..053f3d31010e1e22769d478ec71a4205ed847640 100644 --- a/src/libs/routes/api.js +++ b/src/libs/routes/api.js @@ -116,6 +116,12 @@ const university = require(`${libs}/routes/university`); const universityTeacher = require(`${libs}/routes/universityTeacher`); +const indigenas_infrastructure = require(`${libs}/routes/indigenas_infrastructure`); + +const indigenas_development = require(`${libs}/routes/indigenas_development`); + +const indigenas_rights = require(`${libs}/routes/indigenas_rights`); + api.get('/', (req, res) => { res.json({ msg: 'SMPPIR API is running' }); }); @@ -162,5 +168,8 @@ api.use('/education', education) api.use('/taxa_homicidios', taxa_homicidios) api.use('/traditional_families', traditional_families) api.use('/traditional_families_people', traditional_families_people) +api.use('/indigenas_infrastructure', indigenas_infrastructure) +api.use('/indigenas_development', indigenas_development) +api.use('/indigenas_rights', indigenas_rights) module.exports = api;