-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from analytics-ufcg/dev
Dev
- Loading branch information
Showing
12 changed files
with
224 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* Arquivo: controllers/contratos.controller.js | ||
* Descrição: arquivo responsável por recuperar informações relacionadas aos | ||
* contratos. | ||
*/ | ||
|
||
const models = require("../models/index.model"); | ||
const Contrato = models.contrato; | ||
const Op = models.Sequelize.Op; | ||
|
||
const BAD_REQUEST = 400; | ||
const SUCCESS = 200; | ||
|
||
// Retorna todas os contratos de um município | ||
exports.getContratosPorMunicipio = (req, res) => { | ||
const cd_municipio = req.query.cd_municipio | ||
|
||
Contrato.findAll({ where: { | ||
cd_municipio: cd_municipio | ||
}}) | ||
.then(contratos => res.status(SUCCESS).json(contratos)) | ||
.catch(err => res.status(BAD_REQUEST).json({ err })); | ||
}; | ||
|
||
// Recupera o contrato pelo ID | ||
exports.getContratoById = (req, res) => { | ||
const id = req.params.id | ||
|
||
Contrato.findOne({ | ||
where: { | ||
id_contrato: id | ||
} | ||
}) | ||
.then(contratos => res.json(contratos)) | ||
.catch(err => res.status(BAD_REQUEST).json({ err })); | ||
} | ||
|
||
// Recupera todos os contratos de uma licitação | ||
exports.getContratosByLicitacao = (req, res) => { | ||
const id_licitacao = req.params.id_licitacao | ||
|
||
Contrato.findAll({ | ||
where: { | ||
id_licitacao: id_licitacao | ||
} | ||
}) | ||
.then(contratos => res.json(contratos)) | ||
.catch(err => res.status(BAD_REQUEST).json({ err })); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Arquivo: models/contrato.model.js | ||
* Descrição: arquivo com o modelo do contrato. | ||
*/ | ||
|
||
module.exports = (sequelize, type) => { | ||
Contrato = sequelize.define( | ||
"contrato", | ||
{ | ||
id_contrato: { | ||
type: type.STRING, | ||
primaryKey: true | ||
}, | ||
id_licitacao: type.STRING, | ||
cd_municipio: type.STRING, | ||
cd_u_gestora: type.INTEGER, | ||
dt_ano: type.INTEGER, | ||
nu_contrato: type.STRING, | ||
dt_assinatura: type.DATE, | ||
pr_vigencia: type.DATE, | ||
nu_cpfcnpj: type.STRING, | ||
nu_licitacao: type.STRING, | ||
tp_licitacao: type.INTEGER, | ||
vl_total_contrato: type.INTEGER, | ||
de_obs: type.STRING, | ||
dt_mes_ano: type.STRING, | ||
registro_cge: type.STRING, | ||
cd_siafi: type.STRING, | ||
dt_recebimento: type.DATE, | ||
foto: type.STRING, | ||
planilha: type.STRING, | ||
ordem_servico : type.STRING | ||
}, | ||
{ | ||
freezeTableName: true, | ||
timestamps: false | ||
} | ||
|
||
); | ||
return Contrato; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Arquivo: src/routes/contratos.routes.js | ||
* Descrição: arquivo responsável pelas rotas da api relacionadas a classe 'Contratos'. | ||
*/ | ||
|
||
const router = require('express-promise-router')(); | ||
const contratosController = require('../controllers/contratos.controller'); | ||
|
||
// Busca todos os contratos de um município | ||
// Exemplo: http://localhost:3000/api/contratos/municipio?cd_municipio=012 | ||
router.get('/contratos/municipio', contratosController.getContratosPorMunicipio) | ||
|
||
// Busca um contrato pelo seu ID | ||
// Exemplo: http://localhost:3000/api/contratos/e233520a006288d0caaf70f5bea2f64b | ||
router.get('/contratos/:id', contratosController.getContratoById) | ||
|
||
// Busca todos os contratos de uma licitação | ||
// Exemplo: http://localhost:3000/api/licitacoes/b06aa4ae558ddaaaeecac2ca4aa2e186/contratos | ||
router.get('/licitacoes/:id_licitacao/contratos', contratosController.getContratosByLicitacao) | ||
|
||
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters