registro primer grado a medias
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const CarreraDiaHora = require(`${dbPath}/CarreraDiaHora`);
|
||||
const DiaHora = require(`${dbPath}/DiaHora`);
|
||||
const Grupo = require(`${dbPath}/Grupo`);
|
||||
const PrimerSemestre = require(`${dbPath}/PrimerSemestre`);
|
||||
|
||||
const get = async (body) => {
|
||||
const idCarrera = validar.validarId(body.idCarrera);
|
||||
const idGrupo = validar.validarId(body.idGrupo);
|
||||
const idDiaHora = validar.validarId(body.idDiaHora);
|
||||
const numeroCuenta = validar.validarNumeroCuenta(body.numeroCuenta);
|
||||
const nombre = validar.validarTexto(body.nombre, 'El Nombre', 70);
|
||||
const correo = validar.validarCorreo(body.correo);
|
||||
|
||||
/*
|
||||
Falta
|
||||
Enviar correo con qr de confirmación de su registro a su
|
||||
email
|
||||
Verificar que Dia Hora pertenezca a CarreraDiaHora
|
||||
*/
|
||||
|
||||
return Carrera.findOne({ where: { idCarrera } })
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe esta carrera.');
|
||||
return Grupo.findOne({
|
||||
where: { idGrupo },
|
||||
});
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe este grupo.');
|
||||
return Grupo.findOne({ where: { idGrupo, idCarrera } });
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res)
|
||||
throw new Error('Este grupo no pertenece a la carrera indicada.');
|
||||
return DiaHora.findOne({ where: { idDiaHora } });
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('Ese horario no existe.');
|
||||
return PrimerSemestre.findOne({ where: { numeroCuenta } });
|
||||
})
|
||||
.then((res) => {
|
||||
if (res) throw new Error('Ya se registro a este alumno al recorrido.');
|
||||
return PrimerSemestre.create({
|
||||
numeroCuenta,
|
||||
nombre,
|
||||
correo,
|
||||
idDiaHora,
|
||||
idGrupo,
|
||||
});
|
||||
})
|
||||
.then((res) => ({
|
||||
message: 'Se ha registrado correctamente al alumno al recorrido.',
|
||||
}));
|
||||
};
|
||||
|
||||
module.exports = get;
|
||||
@@ -7,6 +7,10 @@ const TercerSemestre = require(`${dbPath}/TercerSemestre`);
|
||||
const get = async (body) => {
|
||||
const numeroCuenta = validarNumeroCuenta(body.numeroCuenta);
|
||||
|
||||
/*
|
||||
Falta
|
||||
Buscar el horario que le toca
|
||||
*/
|
||||
return TercerSemestre.findOne({
|
||||
where: { numeroCuenta },
|
||||
include: [{ model: Grupo, include: [{ model: Carrera }] }],
|
||||
|
||||
@@ -5,6 +5,11 @@ const TercerSemestre = require(`${dbPath}/TercerSemestre`);
|
||||
const get = async (body) => {
|
||||
const idTercerSemestre = validarId(body.idTercerSemestre);
|
||||
|
||||
/*
|
||||
Falta
|
||||
Enviar correo con qr de confirmación de su registro a su
|
||||
email pcpuma
|
||||
*/
|
||||
return TercerSemestre.findOne({ where: { idTercerSemestre } })
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe esta alumno.');
|
||||
|
||||
Reference in New Issue
Block a user