mini cambios#
This commit is contained in:
@@ -95,15 +95,17 @@ const cargaMasiva = async (file) => {
|
||||
{
|
||||
model: Carrito,
|
||||
include: [{ model: TipoCarrito }, { model: Modulo }],
|
||||
attributes: ['idCarrito', 'sobrenombre'],
|
||||
},
|
||||
],
|
||||
attributes: [
|
||||
'idEquipo',
|
||||
'numeroSerie',
|
||||
'numeroInventario',
|
||||
'sobrenombre',
|
||||
],
|
||||
})
|
||||
);
|
||||
delete existeEquipo.dataValues.idStatus;
|
||||
delete existeEquipo.dataValues.idCarrito;
|
||||
delete existeEquipo.dataValues.idPrograma;
|
||||
delete existeEquipo.dataValues.Carrito.dataValues.idModulo;
|
||||
delete existeEquipo.dataValues.Carrito.dataValues.idTipoCarrito;
|
||||
equiposNuevos.push(existeEquipo);
|
||||
}
|
||||
await eliminarArchivo(path);
|
||||
|
||||
@@ -4,8 +4,8 @@ const Equipo = require(`${dbPath}/Equipo`);
|
||||
const Modulo = require(`${dbPath}/Modulo`);
|
||||
const TipoCarrito = require(`${dbPath}/TipoCarrito`);
|
||||
|
||||
const equipos = async () => {
|
||||
return Carrito.findAll({
|
||||
const equipos = async () =>
|
||||
Carrito.findAll({
|
||||
include: [{ model: TipoCarrito }, { model: Modulo }],
|
||||
attributes: ['idCarrito', 'sobrenombre', 'activo'],
|
||||
}).then(async (res) => {
|
||||
@@ -21,6 +21,5 @@ const equipos = async () => {
|
||||
});
|
||||
return res;
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = equipos;
|
||||
|
||||
@@ -22,24 +22,30 @@ const update = async (body) => {
|
||||
: null;
|
||||
let update = {};
|
||||
|
||||
if (idStatus)
|
||||
await Status.findOne({ where: { idStatus } }).then((res) => {
|
||||
if (!res) throw new Error('No existe este status.');
|
||||
update.idStatus = idStatus;
|
||||
});
|
||||
if (idCarrito)
|
||||
await Carrito.findOne({ where: { idCarrito } }).then((res) => {
|
||||
if (!res) throw new Error('No existe este carrito.');
|
||||
update.idCarrito = idCarrito;
|
||||
});
|
||||
if (idPrograma)
|
||||
await Programa.findOne({ where: { idPrograma } }).then((res) => {
|
||||
if (!res) throw new Error('No existe este programa.');
|
||||
update.idPrograma = idPrograma;
|
||||
});
|
||||
if (validar.validarObjetoVacio(update))
|
||||
throw new Error('No se envio nada para actualizar.');
|
||||
return Equipo.findOne({ where: { idEquipo } })
|
||||
return Status.findOne({ where: { idStatus } })
|
||||
.then((res) => {
|
||||
if (idStatus) {
|
||||
if (!res) throw new Error('No existe este status.');
|
||||
update.idStatus = idStatus;
|
||||
}
|
||||
return Carrito.findOne({ where: { idCarrito } });
|
||||
})
|
||||
.then((res) => {
|
||||
if (idCarrito) {
|
||||
if (!res) throw new Error('No existe este carrito.');
|
||||
update.idCarrito = idCarrito;
|
||||
}
|
||||
return Programa.findOne({ where: { idPrograma } });
|
||||
})
|
||||
.then((res) => {
|
||||
if (idPrograma) {
|
||||
if (!res) throw new Error('No existe este programa.');
|
||||
update.idPrograma = idPrograma;
|
||||
}
|
||||
if (validar.validarObjetoVacio(update))
|
||||
throw new Error('No se envio nada para actualizar.');
|
||||
return Equipo.findOne({ where: { idEquipo } });
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe este equipo.');
|
||||
return Equipo.update(update, { where: { idEquipo } });
|
||||
|
||||
Reference in New Issue
Block a user