traer servicios sociales de back para el admin
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
const serviciosAdmin = (body) => {
|
||||
Servicio.findAll().then((res) => {
|
||||
return res;
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
const Usuario = require('../../db/tablas/Usuario');
|
||||
|
||||
const serviciosAdmin = async (body) => {
|
||||
let pagina = body.pagina;
|
||||
let nombre = body.nombre;
|
||||
let numeroCuenta = body.numeroCuenta;
|
||||
let idStatus = body.idStatus;
|
||||
|
||||
return Servicio.findAll({ include: { model: Usuario } }).then((res) => {
|
||||
let data = [];
|
||||
|
||||
for (let i = pagina * 25 - 25; i < res.length && i < pagina * 25; i++)
|
||||
data.push(res[i]);
|
||||
return {
|
||||
registros: res.length,
|
||||
faltantes: res.length - data.length - (pagina - 1) * 25,
|
||||
servicios: data,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = serviciosAdmin;
|
||||
@@ -11,6 +11,7 @@ const dataResponsable = async () => {
|
||||
await Usuario.create({
|
||||
usuario: correos[i],
|
||||
idTipoUsuario: 2,
|
||||
nombre: nombres[i],
|
||||
activo: true,
|
||||
});
|
||||
console.log(`Se inserto el responsable ${nombres[i]}`.magenta);
|
||||
|
||||
+11
-10
@@ -2,7 +2,7 @@ const express = require('express');
|
||||
const app = express();
|
||||
const route = '/servicio';
|
||||
const nuevo = require('../controller/Servicio/nuevo');
|
||||
// const login = require('../controller/Usuario/login');
|
||||
const serviciosAdmin = require('../controller/Servicio/serviciosAdmin');
|
||||
|
||||
app.post(`${route}/nuevo`, (req, res) => {
|
||||
return nuevo(req.body)
|
||||
@@ -14,14 +14,15 @@ app.post(`${route}/nuevo`, (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
// app.post(`${route}/login`, (req, res) => {
|
||||
// return login(req.body)
|
||||
// .then((data) => {
|
||||
// res.status(201).json(data);
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// res.status(400).json({ message: err.message });
|
||||
// });
|
||||
// });
|
||||
app.get(`${route}/serviciosAdmin`, (req, res) => {
|
||||
return serviciosAdmin(req.query)
|
||||
.then((data) => {
|
||||
console.log(data)
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = app;
|
||||
|
||||
Reference in New Issue
Block a user