get alumno y horarios

This commit is contained in:
2021-10-23 06:14:30 -05:00
parent b42a88e9ac
commit 2c14d4ee08
5 changed files with 39 additions and 60 deletions
+12 -28
View File
@@ -1,35 +1,19 @@
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 Carrera = require(`${dbPath}/Carrera`);
const Alumno = require(`${dbPath}/Alumno`);
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 };
// });
const numeroCuenta = validarNumeroCuenta(body.numeroCuenta);
return Alumno.findOne({
where: { numeroCuenta },
include: [{ model: Carrera }],
}).then((res) => {
if (!res) throw new Error('No existe este número de cuenta.');
delete res.idCarrera;
return res;
});
};
module.exports = get;
+5 -29
View File
@@ -1,35 +1,11 @@
const { validarNumeroCuenta } = require('../../helper/validar');
const { validarTexto, validar } = 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 Horario = require(`${dbPath}/Horario`);
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 };
// });
const turno = validarTexto(body.turno, 'El turno', 1);
return Horario.findAll({ where: { turno } });
};
module.exports = get;
+2 -2
View File
@@ -1,7 +1,7 @@
const express = require('express');
const app = express();
const route = '/tercer_semestre';
const controllerPath = '../controller/TercerSemestre';
const route = '/alumno';
const controllerPath = '../controller/Alumno';
const get = require(`${controllerPath}/get`);
// GET
+18
View File
@@ -0,0 +1,18 @@
const express = require('express');
const app = express();
const route = '/horario';
const controllerPath = '../controller/Horario';
const get = require(`${controllerPath}/get`);
// GET
app.get(`${route}`, (req, res) => {
return get(req.query)
.then((data) => {
res.status(200).json(data);
})
.catch((err) => {
res.status(400).json({ message: err.message });
});
});
module.exports = app;
+2 -1
View File
@@ -2,6 +2,7 @@ const express = require('express');
const app = express();
app.use(require('./Alumno'));
app.use(require('./AlumnoHorario'));
// app.use(require('./AlumnoHorario'));
app.use(require('./Horario'));
module.exports = app;