get endpoints prestamos
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Prestamo = require(`${dbPath}/Prestamo`);
|
||||
const Equipo = require(`${dbPath}/Equipo`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
const TipoUsuario = require(`${dbPath}/TipoUsuario`);
|
||||
const Carrito = require(`${dbPath}/Carrito`);
|
||||
const Modulo = require(`${dbPath}/Modulo`);
|
||||
const TipoCarrito = require(`${dbPath}/TipoCarrito`);
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
|
||||
const activos = async (body) => {
|
||||
return Prestamo.findAll({
|
||||
include: [
|
||||
{
|
||||
model: Equipo,
|
||||
where: { activo: true },
|
||||
include: [
|
||||
{
|
||||
model: Carrito,
|
||||
include: [{ model: TipoCarrito }, { model: Modulo }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{ model: Usuario, include: [{ model: TipoUsuario }, { model: Carrera }] },
|
||||
],
|
||||
}).then((res) => {
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
delete res[i].dataValues.idUsuario;
|
||||
delete res[i].dataValues.idOperadorEntrega;
|
||||
delete res[i].dataValues.idEquipo;
|
||||
delete res[i].dataValues.idStatus;
|
||||
delete res[i].dataValues.Carrito.dataValues.idTipoCarrito;
|
||||
delete res[i].dataValues.Carrito.dataValues.idModulo;
|
||||
delete res[i].dataValues.Usuario.dataValues.idTipoUsuario;
|
||||
delete res[i].dataValues.Usuario.dataValues.idCarrera;
|
||||
if (res[i].idPrograma) delete res[i].dataValues.idPrograma;
|
||||
}
|
||||
return { activos: res };
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = activos;
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Prestamo = require(`${dbPath}/Prestamo`);
|
||||
const Equipo = require(`${dbPath}/Equipo`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
const TipoUsuario = require(`${dbPath}/TipoUsuario`);
|
||||
const Carrito = require(`${dbPath}/Carrito`);
|
||||
const Modulo = require(`${dbPath}/Modulo`);
|
||||
const TipoCarrito = require(`${dbPath}/TipoCarrito`);
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
|
||||
const historial = async (body) => {
|
||||
return Prestamo.findAll({
|
||||
include: [
|
||||
{
|
||||
model: Equipo,
|
||||
include: [
|
||||
{
|
||||
model: Carrito,
|
||||
include: [{ model: TipoCarrito }, { model: Modulo }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{ model: Usuario, include: [{ model: TipoUsuario }, { model: Carrera }] },
|
||||
],
|
||||
}).then((res) => {
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
delete res[i].dataValues.idUsuario;
|
||||
delete res[i].dataValues.idOperadorEntrega;
|
||||
delete res[i].dataValues.idEquipo;
|
||||
delete res[i].dataValues.idStatus;
|
||||
delete res[i].dataValues.Carrito.dataValues.idTipoCarrito;
|
||||
delete res[i].dataValues.Carrito.dataValues.idModulo;
|
||||
delete res[i].dataValues.Usuario.dataValues.idTipoUsuario;
|
||||
delete res[i].dataValues.Usuario.dataValues.idCarrera;
|
||||
if (res[i].idPrograma) delete res[i].dataValues.idPrograma;
|
||||
}
|
||||
return { historial: res };
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = historial;
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Prestamo = require(`${dbPath}/Prestamo`);
|
||||
const Equipo = require(`${dbPath}/Equipo`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
const TipoUsuario = require(`${dbPath}/TipoUsuario`);
|
||||
const Carrito = require(`${dbPath}/Carrito`);
|
||||
const Modulo = require(`${dbPath}/Modulo`);
|
||||
const TipoCarrito = require(`${dbPath}/TipoCarrito`);
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
|
||||
const historialEquipo = async (body) => {
|
||||
let numeroSerie = validar.validarAlfanumerico(
|
||||
body.numeroSerie,
|
||||
'El numero de serie',
|
||||
20
|
||||
);
|
||||
|
||||
return Prestamo.findAll({
|
||||
include: [
|
||||
{
|
||||
model: Equipo,
|
||||
where: { numeroSerie },
|
||||
include: [
|
||||
{
|
||||
model: Carrito,
|
||||
include: [{ model: TipoCarrito }, { model: Modulo }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{ model: Usuario, include: [{ model: TipoUsuario }, { model: Carrera }] },
|
||||
],
|
||||
}).then((res) => {
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
delete res[i].dataValues.idUsuario;
|
||||
delete res[i].dataValues.idOperadorEntrega;
|
||||
delete res[i].dataValues.idEquipo;
|
||||
delete res[i].dataValues.idStatus;
|
||||
delete res[i].dataValues.Carrito.dataValues.idTipoCarrito;
|
||||
delete res[i].dataValues.Carrito.dataValues.idModulo;
|
||||
delete res[i].dataValues.Usuario.dataValues.idTipoUsuario;
|
||||
delete res[i].dataValues.Usuario.dataValues.idCarrera;
|
||||
if (res[i].idPrograma) delete res[i].dataValues.idPrograma;
|
||||
}
|
||||
return { historialEquipo: res };
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = historialEquipo;
|
||||
@@ -0,0 +1,48 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Prestamo = require(`${dbPath}/Prestamo`);
|
||||
const Equipo = require(`${dbPath}/Equipo`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
const TipoUsuario = require(`${dbPath}/TipoUsuario`);
|
||||
const Carrito = require(`${dbPath}/Carrito`);
|
||||
const Modulo = require(`${dbPath}/Modulo`);
|
||||
const TipoCarrito = require(`${dbPath}/TipoCarrito`);
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
|
||||
const historialUsuario = async (body) => {
|
||||
let usuario = validar.validarNumeroCuenta(body.noCuenta);
|
||||
|
||||
return Prestamo.findAll({
|
||||
include: [
|
||||
{
|
||||
model: Equipo,
|
||||
include: [
|
||||
{
|
||||
model: Carrito,
|
||||
include: [{ model: TipoCarrito }, { model: Modulo }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
model: Usuario,
|
||||
where: { usuario },
|
||||
include: [{ model: TipoUsuario }, { model: Carrera }],
|
||||
},
|
||||
],
|
||||
}).then((res) => {
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
delete res[i].dataValues.idUsuario;
|
||||
delete res[i].dataValues.idOperadorEntrega;
|
||||
delete res[i].dataValues.idEquipo;
|
||||
delete res[i].dataValues.idStatus;
|
||||
delete res[i].dataValues.Carrito.dataValues.idTipoCarrito;
|
||||
delete res[i].dataValues.Carrito.dataValues.idModulo;
|
||||
delete res[i].dataValues.Usuario.dataValues.idTipoUsuario;
|
||||
delete res[i].dataValues.Usuario.dataValues.idCarrera;
|
||||
if (res[i].idPrograma) delete res[i].dataValues.idPrograma;
|
||||
}
|
||||
return { historialUsuario: res };
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = historialUsuario;
|
||||
|
||||
Reference in New Issue
Block a user