31 lines
1010 B
JavaScript
31 lines
1010 B
JavaScript
const helperPath = '../../helper';
|
|
const validar = require(`${helperPath}/validar`);
|
|
const dbPath = '../../db/tablas';
|
|
const Carrera = require(`${dbPath}/Carrera`);
|
|
const Grupo = require(`${dbPath}/Grupo`);
|
|
const GrupoHorario = require(`${dbPath}/GrupoHorario`);
|
|
const Horario = require(`${dbPath}/Horario`);
|
|
const TercerSemestre = require(`${dbPath}/TercerSemestre`);
|
|
|
|
const asistentes = async (body) => {
|
|
const idHorario = validar.validarId(body.idHorario);
|
|
|
|
return Horario.findOne({ where: { idHorario } })
|
|
.then((res) => {
|
|
if (!res) throw new Error('No existe este horario.');
|
|
return GrupoHorario.findOne({
|
|
where: { idHorario },
|
|
});
|
|
})
|
|
.then((res) => {
|
|
if (!res)
|
|
throw new Error('No hay un grupo que tenga asignado este horario.');
|
|
return TercerSemestre.findAll({
|
|
where: { idGrupo: res.idGrupo, deseaAsistir: true },
|
|
include: [{ model: Grupo, include: [{ model: Carrera }] }],
|
|
});
|
|
});
|
|
};
|
|
|
|
module.exports = asistentes;
|