tercer semestre get alumno

This commit is contained in:
Lemuel Marquez
2021-07-11 00:42:05 -05:00
parent 3c781cffac
commit e092a7742f
5 changed files with 65 additions and 15 deletions
+2 -2
View File
@@ -4,7 +4,7 @@ const dbPath = '../../db/tablas';
const Carrera = require(`${dbPath}/Carrera`);
const Grupo = require(`${dbPath}/Grupo`);
const admin = async (body) => {
const get = async (body) => {
const idCarrera = validarId(body.idCarrera);
return Carrera.findOne({ where: { idCarrera } })
@@ -19,4 +19,4 @@ const admin = async (body) => {
});
};
module.exports = admin;
module.exports = get;
+24
View File
@@ -0,0 +1,24 @@
const { Op } = require('sequelize');
const { validarNumeroCuenta } = require('../../helper/validar');
const dbPath = '../../db/tablas';
const Carrera = require(`${dbPath}/Carrera`);
const Grupo = require(`${dbPath}/Grupo`);
const TercerSemestre = require(`${dbPath}/TercerSemestre`);
const get = async (body) => {
const numeroCuenta = validarNumeroCuenta(body.numeroCuenta);
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('Ta se registro a este alumno al recorrido.');
delete res.dataValues.idGrupo;
delete res.dataValues.Grupo.dataValues.idCarrera;
return res;
});
};
module.exports = get;