68 lines
1.6 KiB
JavaScript
68 lines
1.6 KiB
JavaScript
const { validarNumeroEntero } = require('../../helper/validar');
|
|
const dbPath = '../../db/tablas';
|
|
const Carrera = require(`${dbPath}/Carrera`);
|
|
const Programa = require(`${dbPath}/Programa`);
|
|
const Servicio = require(`${dbPath}/Servicio`);
|
|
const Status = require(`${dbPath}/Status`);
|
|
const TipoUsuario = require(`${dbPath}/TipoUsuario`);
|
|
const Usuario = require(`${dbPath}/Usuario`);
|
|
|
|
const admin = async (body) => {
|
|
const idServicio = validarNumeroEntero(body.idServicio, 'id servicio');
|
|
|
|
return Servicio.findOne({
|
|
where: { idServicio },
|
|
include: [
|
|
{
|
|
model: Usuario,
|
|
include: [{ model: TipoUsuario }],
|
|
attributes: ['idUsuario', 'usuario', 'nombre'],
|
|
},
|
|
{ model: Carrera },
|
|
{ model: Status },
|
|
{
|
|
model: Programa,
|
|
include: [
|
|
{
|
|
model: Usuario,
|
|
attributes: ['idUsuario', 'usuario', 'nombre'],
|
|
},
|
|
],
|
|
attributes: [
|
|
'idPrograma',
|
|
'institucion',
|
|
'dependencia',
|
|
'programa',
|
|
'clavePrograma',
|
|
'acatlan',
|
|
],
|
|
},
|
|
],
|
|
attributes: [
|
|
'idServicio',
|
|
'creditos',
|
|
'correo',
|
|
'telefono',
|
|
'direccion',
|
|
'fechaInicio',
|
|
'fechaFin',
|
|
'fechaLiberacion',
|
|
'fechaNacimiento',
|
|
'cartaAceptacion',
|
|
'cartaTermino',
|
|
'informeGlobal',
|
|
'programaInterno',
|
|
'profesor',
|
|
'vistoBuenoAcatlan',
|
|
'createdAt',
|
|
'idCuestionarioAlumno',
|
|
'idCuestionarioPrograma',
|
|
],
|
|
}).then((res) => {
|
|
if (!res) throw new Error('No existe este servicio social.');
|
|
return res;
|
|
});
|
|
};
|
|
|
|
module.exports = admin;
|