37 lines
1.3 KiB
JavaScript
37 lines
1.3 KiB
JavaScript
const { validarNumeroCuenta } = require('../../helper/validar');
|
|
const dbPath = '../../db/tablas';
|
|
const Carrera = require(`${dbPath}/Carrera`);
|
|
const Grupo = require(`${dbPath}/Grupo`);
|
|
const Horario = require(`${dbPath}/Horario`);
|
|
const GrupoHorario = require(`${dbPath}/GrupoHorario`);
|
|
const TercerSemestre = require(`${dbPath}/TercerSemestre`);
|
|
|
|
const get = async (body) => {
|
|
const numeroCuenta = validarNumeroCuenta(body.numeroCuenta);
|
|
let alumnoTercerSemestre = {};
|
|
|
|
return TercerSemestre.findOne({
|
|
where: { numeroCuenta },
|
|
include: [{ model: Grupo, include: [{ model: Carrera }] }],
|
|
})
|
|
.then((res) => {
|
|
if (!res) throw new Error('No existe esta alumno.');
|
|
if (res.deseaAsistir)
|
|
throw new Error('Ya se registro a este alumno al recorrido.');
|
|
alumnoTercerSemestre = res;
|
|
delete alumnoTercerSemestre.dataValues.idGrupo;
|
|
delete alumnoTercerSemestre.dataValues.Grupo.dataValues.idCarrera;
|
|
return GrupoHorario.findOne({
|
|
where: { idGrupo: alumnoTercerSemestre.Grupo.idGrupo },
|
|
include: [{ model: Horario }],
|
|
});
|
|
})
|
|
.then((res) => {
|
|
delete res.dataValues.idHorario;
|
|
delete res.dataValues.idGrupo;
|
|
return { alumnoTercerSemestre, GrupoHorario: res };
|
|
});
|
|
};
|
|
|
|
module.exports = get;
|