terminada

This commit is contained in:
2022-05-17 00:01:12 -05:00
parent 41cdbe07e5
commit b03c77658a
3 changed files with 26 additions and 2 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ yarn-debug.log*
yarn-error.log*
lerna-debug.log*
uploads/*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
@@ -0,0 +1,13 @@
const Premiacion = require('../../db/tablas/Premiacion');
const { validarNumeroEntero } = require('../../helper/validar');
const getPaginacion = async (query) => {
const pagina = validarNumeroEntero(query.pagina, 'página', false);
return Premiacion.findAndCountAll({
limit: 25,
offset: 25 * (pagina - 1),
});
};
module.exports = getPaginacion;
+12 -1
View File
@@ -4,12 +4,23 @@ const app = express();
const route = '/premiacion';
const controllerPath = '../controller/Premiacion';
const get = require(`${controllerPath}/premiaciones`);
const getPaginacion = require(`${controllerPath}/premiacionesPaginacion`);
const editar = require(`${controllerPath}/editar`);
const nueva = require(`${controllerPath}/nueva`);
const activarDesactivar = require(`${controllerPath}/activarDesactivar`);
app.get(`${route}/get`, (req, res) => {
return get(req.query)
return get()
.then((data) => {
res.status(200).json(data);
})
.catch((err) => {
res.status(400).json({ message: err.message });
});
});
app.get(`${route}/premiacionesPaginacion`, (req, res) => {
return getPaginacion(req.query)
.then((data) => {
res.status(200).json(data);
})