Files
pcpuma_acatlan_api/server/controller/Equipo/equipo.js
T

37 lines
1.0 KiB
JavaScript
Raw Normal View History

2021-05-18 22:40:30 -05:00
const { validarAlfanumerico } = require('../../helper/validar');
2021-05-03 23:38:03 -05:00
const dbPath = '../../db/tablas';
const Carrito = require(`${dbPath}/Carrito`);
const Equipo = require(`${dbPath}/Equipo`);
const Modulo = require(`${dbPath}/Modulo`);
const Programa = require(`${dbPath}/Programa`);
const Status = require(`${dbPath}/Status`);
const TipoCarrito = require(`${dbPath}/TipoCarrito`);
2021-04-29 19:43:33 -05:00
2021-05-04 00:32:04 -05:00
const equipo = async (body) => {
2021-05-26 16:39:07 -05:00
const numeroInventario = validarAlfanumerico(
2021-05-24 15:14:49 -05:00
body.numeroInventario,
2022-01-03 16:56:00 -06:00
'numero de inventario',
true,
2021-04-29 19:43:33 -05:00
20
);
return Equipo.findOne({
2021-05-24 15:14:49 -05:00
where: { numeroInventario },
2021-04-29 19:43:33 -05:00
include: [
2022-01-20 22:01:14 -06:00
{
model: Carrito,
include: [{ model: TipoCarrito }, { model: Modulo }],
attributes: ['idCarrito', 'sobrenombre', 'activo'],
},
2021-04-29 19:43:33 -05:00
{ model: Status },
{ model: Programa },
],
2022-01-20 23:41:44 -06:00
attributes: ['idEquipo', 'numeroSerie', 'numeroInventario', 'sobrenombre'],
2021-04-29 19:43:33 -05:00
}).then((res) => {
if (!res) throw new Error('No existe este equipo.');
return res;
});
};
2021-05-04 00:32:04 -05:00
module.exports = equipo;