33 lines
975 B
JavaScript
33 lines
975 B
JavaScript
const { validarNumeroEntero } = require('../../helper/validar');
|
|
const dbPath = '../../db/tablas';
|
|
const Carrera = require(`${dbPath}/Carrera`);
|
|
const CasoEspecial = require(`${dbPath}/CasoEspecial`);
|
|
const Status = require(`${dbPath}/Status`);
|
|
const TipoUsuario = require(`${dbPath}/TipoUsuario`);
|
|
const Usuario = require(`${dbPath}/Usuario`);
|
|
|
|
const admin = async (body) => {
|
|
const idCasoEspecial = validarNumeroEntero(
|
|
body.idCasoEspecial,
|
|
'id caso especial'
|
|
);
|
|
|
|
return CasoEspecial.findOne({
|
|
where: { idCasoEspecial },
|
|
include: [
|
|
{ model: Usuario, include: [{ model: TipoUsuario }] },
|
|
{ model: Carrera },
|
|
{ model: Status },
|
|
],
|
|
}).then((res) => {
|
|
if (!res) throw new Error('No existe este Caso Especial.');
|
|
delete res.dataValues.Usuario.dataValues.password;
|
|
delete res.dataValues.idUsuario;
|
|
delete res.dataValues.idCarrera;
|
|
delete res.dataValues.idStatus;
|
|
return res;
|
|
});
|
|
};
|
|
|
|
module.exports = admin;
|