This commit is contained in:
xXpuma99Xx
2021-10-22 23:46:31 -05:00
parent 6df2978665
commit 64b94de562
36 changed files with 1152 additions and 2198 deletions
+997 -822
View File
File diff suppressed because it is too large Load Diff
+35
View File
@@ -0,0 +1,35 @@
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;
-5
View File
@@ -1,5 +0,0 @@
const Carrera = require('../../db/tablas/Carrera');
const get = async () => Carrera.findAll();
module.exports = get;
-37
View File
@@ -1,37 +0,0 @@
const { validarId } = require('../../helper/validar');
const dbPath = '../../db/tablas';
const Carrera = require(`${dbPath}/Carrera`);
const CarreraHorario = require(`${dbPath}/CarreraHorario`);
const Horario = require(`${dbPath}/Horario`);
const PrimerSemestre = require(`${dbPath}/PrimerSemestre`);
const get = async (body) => {
const idCarrera = validarId(body.idCarrera);
const data = [];
return Carrera.findOne({ where: { idCarrera } })
.then((res) => {
if (!res) throw new Error('No existe esta carrera.');
return CarreraHorario.findAll({
where: { idCarrera },
include: [{ model: Horario }],
});
})
.then(async (res) => {
for (let i = 0; i < res.length; i++) {
const lugaresOcupados = await PrimerSemestre.findAll({
where: { idHorario: res[i].Horario.idHorario },
}).then((res) => res.length);
if (lugaresOcupados < 45)
data.push({
idHorario: res[i].Horario.idHorario,
horario: res[i].Horario.horario,
lugares: 45 - lugaresOcupados,
});
}
return data;
});
};
module.exports = get;
@@ -1,21 +0,0 @@
const moment = require('moment');
const dbPath = '../../db/tablas';
const CarreraHorario = require(`${dbPath}/CarreraHorario`);
const Horario = require(`${dbPath}/Horario`);
const hoy = moment();
const horariosDia = async (body) => {
const data = [];
return CarreraHorario.findAll({
include: [{ model: Horario }],
order: ['idHorario'],
}).then(async (res) => {
for (let i = 0; i < res.length; i++)
if (hoy.dayOfYear() === moment(res[i].Horario.horario).dayOfYear())
data.push({ Horario: res[i].Horario });
return data;
});
};
module.exports = horariosDia;
@@ -1,25 +0,0 @@
const dbPath = '../../db/tablas';
const Carrera = require(`${dbPath}/Carrera`);
const CarreraHorario = require(`${dbPath}/CarreraHorario`);
const Horario = require(`${dbPath}/Horario`);
const PrimerSemestre = require(`${dbPath}/PrimerSemestre`);
const monitor = async (body) => {
const data = [];
return CarreraHorario.findAll({
include: [{ model: Horario }, { model: Carrera }],
order: ['idHorario'],
}).then(async (res) => {
for (let i = 0; i < res.length; i++) {
const asistentes = await PrimerSemestre.findAll({
where: { idHorario: res[i].idHorario },
}).then((res) => res.length);
data.push({ CarreraHorario: res[i], asistentes });
}
return data;
});
};
module.exports = monitor;
-23
View File
@@ -1,23 +0,0 @@
const { Op } = require('sequelize');
const { validarId } = require('../../helper/validar');
const dbPath = '../../db/tablas';
const Carrera = require(`${dbPath}/Carrera`);
const Grupo = require(`${dbPath}/Grupo`);
const get = async (body) => {
const idCarrera = validarId(body.idCarrera);
return Carrera.findOne({ where: { idCarrera } })
.then((res) => {
if (!res) throw new Error('No existe esta carrera.');
return Grupo.findAll({
where: { idCarrera, grupo: { [Op.like]: '11%' } },
});
})
.then((res) => {
for (let i = 0; i < res.length; i++) delete res[i].dataValues.idCarrera;
return res;
});
};
module.exports = get;
@@ -1,21 +0,0 @@
const moment = require('moment');
const dbPath = '../../db/tablas';
const GrupoHorario = require(`${dbPath}/GrupoHorario`);
const Horario = require(`${dbPath}/Horario`);
const hoy = moment();
const horariosDia = async (body) => {
const data = [];
return GrupoHorario.findAll({
include: [{ model: Horario }],
order: ['idHorario'],
}).then(async (res) => {
for (let i = 0; i < res.length; i++)
if (hoy.dayOfYear() === moment(res[i].Horario.horario).dayOfYear())
data.push({ Horario: res[i].Horario });
return data;
});
};
module.exports = horariosDia;
-29
View File
@@ -1,29 +0,0 @@
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 monitor = async (body) => {
const data = [];
return GrupoHorario.findAll({
include: [
{ model: Horario },
{ model: Grupo, include: [{ model: Carrera }] },
],
order: ['idHorario'],
}).then(async (res) => {
for (let i = 0; i < res.length; i++) {
const asistentes = await TercerSemestre.findAll({
where: { idGrupo: res[i].idGrupo, deseaAsistir: true },
}).then((res) => res.length);
data.push({ GrupoHorario: res[i], asistentes });
}
return data;
});
};
module.exports = monitor;
+35
View File
@@ -0,0 +1,35 @@
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;
@@ -1,26 +0,0 @@
const dbPath = '../../db/tablas';
const Carrera = require(`${dbPath}/Carrera`);
const Grupo = require(`${dbPath}/Grupo`);
const PrimerSemestre = require(`${dbPath}/PrimerSemestre`);
const alumnosCarrera = async (body) => {
const data = [];
return Carrera.findAll().then(async (res) => {
for (let i = 0; i < res.length; i++) {
const alumnos = await PrimerSemestre.findAll({
include: [
{
model: Grupo,
where: { idCarrera: res[i].idCarrera },
},
],
}).then((res) => res.length);
data.push({ Carrera: res[i], alumnos });
}
return data;
});
};
module.exports = alumnosCarrera;
@@ -1,32 +0,0 @@
const moment = require('moment');
const helperPath = '../../helper';
const { validarNumeroCuenta } = require(`${helperPath}/validar`);
const dbPath = '../../db/tablas';
const Horario = require(`${dbPath}/Horario`);
const PrimerSemestre = require(`${dbPath}/PrimerSemestre`);
const hoy = moment();
const asistencia = async (body) => {
const numeroCuenta = validarNumeroCuenta(body.numeroCuenta);
return PrimerSemestre.findOne({
where: { numeroCuenta },
include: [{ model: Horario }],
})
.then((res) => {
if (!res) throw new Error('No existe este alumno.');
if (hoy.dayOfYear() != moment(res.Horario.horario).dayOfYear())
throw new Error('Este alumno no tiene una cita para el día de hoy.');
if (res.asistio)
throw new Error('Ya fue registrada la asistencia de este alumno.');
return PrimerSemestre.update(
{ asistio: true },
{ where: { numeroCuenta } }
);
})
.then((res) => ({
message: 'Se registro correctamente la asistencia de este alumno.',
}));
};
module.exports = asistencia;
@@ -1,21 +0,0 @@
const helperPath = '../../helper';
const validar = require(`${helperPath}/validar`);
const dbPath = '../../db/tablas';
const Carrera = require(`${dbPath}/Carrera`);
const Grupo = require(`${dbPath}/Grupo`);
const Horario = require(`${dbPath}/Horario`);
const PrimerSemestre = require(`${dbPath}/PrimerSemestre`);
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 PrimerSemestre.findAll({
where: { idHorario },
include: [{ model: Grupo, include: [{ model: Carrera }] }],
});
});
};
module.exports = asistentes;
-59
View File
@@ -1,59 +0,0 @@
const moment = require('moment');
const { convertArrayToCSV } = require('convert-array-to-csv');
const helperPath = '../../helper';
const helper = require(`${helperPath}/helper`);
const encriptar = require(`${helperPath}/encriptar`);
const dbPath = '../../db/tablas';
const Carrera = require(`${dbPath}/Carrera`);
const Grupo = require(`${dbPath}/Grupo`);
const Horario = require(`${dbPath}/Horario`);
const PrimerSemestre = require(`${dbPath}/PrimerSemestre`);
const csv = async (body) => {
const path = `server/uploads/primer_semestre.csv`;
const data = [];
if (
!encriptar.comparar(
body.password,
'$2b$10$8FDx15tey9s9ITXNNE/Qourk1EfyrC6W8/ROqI0sGMuyOAuZ8oHMO'
)
)
throw new Error('Contraseña incorrecta.');
return PrimerSemestre.findAll({
include: [{ model: Grupo, include: [{ model: Carrera }] }],
})
.then(async (res) => {
for (let i = 0; i < res.length; i++) {
const horario = await Horario.findOne({
where: { idHorario: res[i].idHorario },
}).then((res) => moment(res.horario));
data.push({
numeroCuenta: res[i].numeroCuenta,
nombre: res[i].nombre,
carrera: res[i].Grupo.Carrera.carrera,
grupo: res[i].Grupo.grupo,
dia: `${
horario.date() < 10 ? '0' + horario.date() : horario.date()
}/${
horario.month() + 1 < 10
? '0' + (horario.month() + 1)
: horario.month() + 1
}/${horario.year()}`,
hora: `${
horario.hour() < 10 ? '0' + horario.hour() : horario.hour()
}:${
horario.minute() < 10 ? '0' + horario.minute() : horario.minute()
}`,
correo: res[i].correo,
asistio: res[i].asistio ? 'si' : 'no',
});
}
await helper.eliminarArchivo(path).catch((err) => {});
return helper.crearArchivo(path, convertArrayToCSV(data));
})
.then((res) => path);
};
module.exports = csv;
@@ -1,85 +0,0 @@
const helperPath = '../../helper';
const gmail = require(`${helperPath}/gmail`);
const correos = require(`${helperPath}/correos`);
const validar = require(`${helperPath}/validar`);
const dbPath = '../../db/tablas';
const Carrera = require(`${dbPath}/Carrera`);
const CarreraHorario = require(`${dbPath}/CarreraHorario`);
const Horario = require(`${dbPath}/Horario`);
const Grupo = require(`${dbPath}/Grupo`);
const PrimerSemestre = require(`${dbPath}/PrimerSemestre`);
const registrar = async (body) => {
const idCarrera = validar.validarId(body.idCarrera);
const idGrupo = validar.validarId(body.idGrupo);
const idHorario = validar.validarId(body.idHorario);
const numeroCuenta = validar.validarNumeroCuenta(body.numeroCuenta);
const correo = validar.validarCorreo(body.correo);
const nombre = validar.validarTexto(body.nombre, 'El nombre', 70);
let mail = {};
let horario = {};
let carrera = {};
return Carrera.findOne({ where: { idCarrera } })
.then((res) => {
if (!res) throw new Error('No existe esta carrera.');
carrera = res;
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.');
if (res.grupo[0] === '2' && res.grupo[1] === '2')
throw new Error(
'Este grupo es de segundo semestre, no es valido para este registro.'
);
return Horario.findOne({ where: { idHorario } });
})
.then((res) => {
if (!res) throw new Error('No existe este horario.');
horario = res;
return CarreraHorario.findOne({ where: { idCarrera, idHorario } });
})
.then((res) => {
if (!res) throw new Error('Esta carrera no tiene asignado este horario.');
return PrimerSemestre.findOne({ where: { numeroCuenta } });
})
.then((res) => {
if (res) throw new Error('Ya se registro a este alumno al recorrido.');
return PrimerSemestre.findAll({
where: { idHorario },
});
})
.then((res) => {
if (res.length >= 45)
throw new Error('Este horario ya esta lleno, elige otro.');
return PrimerSemestre.create({
numeroCuenta,
correo,
nombre,
idHorario,
idGrupo,
});
})
.then((res) => {
mail = correos.correoPrimerSemestre(
res.numeroCuenta,
res.nombre,
carrera.carrera,
horario.horario
);
return gmail(mail.subject, res.correo, mail.message);
})
.then((res) => ({
message:
'Te has registrado correctamente, hemos mandado tu comprobante a tu correo.',
}));
};
module.exports = registrar;
@@ -1,27 +0,0 @@
const dbPath = '../../db/tablas';
const Carrera = require(`${dbPath}/Carrera`);
const Grupo = require(`${dbPath}/Grupo`);
const TercerSemestre = require(`${dbPath}/TercerSemestre`);
const alumnosCarrera = async (body) => {
const data = [];
return Carrera.findAll().then(async (res) => {
for (let i = 0; i < res.length; i++) {
const alumnos = await TercerSemestre.findAll({
where: { deseaAsistir: true },
include: [
{
model: Grupo,
where: { idCarrera: res[i].idCarrera },
},
],
}).then((res) => res.length);
data.push({ Carrera: res[i], alumnos });
}
return data;
});
};
module.exports = alumnosCarrera;
@@ -1,38 +0,0 @@
const moment = require('moment');
const helperPath = '../../helper';
const { validarNumeroCuenta } = require(`${helperPath}/validar`);
const dbPath = '../../db/tablas';
const GrupoHorario = require(`${dbPath}/GrupoHorario`);
const Horario = require(`${dbPath}/Horario`);
const TercerSemestre = require(`${dbPath}/TercerSemestre`);
const hoy = moment();
const asistencia = async (body) => {
const numeroCuenta = validarNumeroCuenta(body.numeroCuenta);
return TercerSemestre.findOne({
where: { numeroCuenta },
})
.then((res) => {
if (!res) throw new Error('No existe este alumno.');
if (res.asistio)
throw new Error('Ya fue registrada la asistencia de este alumno.');
return GrupoHorario.findOne({
where: { idGrupo: res.idGrupo },
include: [{ model: Horario }],
});
})
.then((res) => {
if (hoy.dayOfYear() != moment(res.Horario.horario).dayOfYear())
throw new Error('Este alumno no tiene una cita para el día de hoy.');
return TercerSemestre.update(
{ asistio: true },
{ where: { numeroCuenta } }
);
})
.then((res) => ({
message: 'Se registro correctamente la asistencia de este alumno.',
}));
};
module.exports = asistencia;
@@ -1,30 +0,0 @@
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;
-61
View File
@@ -1,61 +0,0 @@
const { convertArrayToCSV } = require('convert-array-to-csv');
const moment = require('moment');
const helperPath = '../../helper';
const helper = require(`${helperPath}/helper`);
const encriptar = require(`${helperPath}/encriptar`);
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 csv = async (body) => {
const path = `server/uploads/tercer_semestre.csv`;
const data = [];
if (
!encriptar.comparar(
body.password,
'$2b$10$8FDx15tey9s9ITXNNE/Qourk1EfyrC6W8/ROqI0sGMuyOAuZ8oHMO'
)
)
throw new Error('Contraseña incorrecta.');
return TercerSemestre.findAll({
where: { deseaAsistir: true },
include: [{ model: Grupo, include: [{ model: Carrera }] }],
})
.then(async (res) => {
for (let i = 0; i < res.length; i++) {
const horario = await GrupoHorario.findOne({
where: { idGrupo: res[i].idGrupo },
include: [{ model: Horario }],
}).then((res) => moment(res.Horario.horario));
data.push({
numeroCuenta: res[i].numeroCuenta,
nombre: res[i].nombre,
carrera: res[i].Grupo.Carrera.carrera,
grupo: res[i].Grupo.grupo,
dia: `${
horario.date() < 10 ? '0' + horario.date() : horario.date()
}/${
horario.month() + 1 < 10
? '0' + (horario.month() + 1)
: horario.month() + 1
}/${horario.year()}`,
hora: `${
horario.hour() < 10 ? '0' + horario.hour() : horario.hour()
}:${
horario.minute() < 10 ? '0' + horario.minute() : horario.minute()
}`,
asistio: res[i].asistio ? 'si' : 'no',
});
}
await helper.eliminarArchivo(path).catch((err) => {});
return helper.crearArchivo(path, convertArrayToCSV(data));
})
.then((res) => path);
};
module.exports = csv;
-36
View File
@@ -1,36 +0,0 @@
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;
@@ -1,57 +0,0 @@
const helperPath = '../../helper';
const gmail = require(`${helperPath}/gmail`);
const correos = require(`${helperPath}/correos`);
const { validarId } = 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 registrar = async (body) => {
const idTercerSemestre = validarId(body.idTercerSemestre);
let alumno = {};
let mail = {};
return TercerSemestre.findOne({
where: { idTercerSemestre },
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.');
alumno = res;
return GrupoHorario.findOne({
where: { idGrupo: alumno.idGrupo },
include: [{ model: Horario }],
});
})
.then((res) => {
mail = correos.correoTercerSemestre(
alumno.numeroCuenta,
alumno.nombre,
alumno.Grupo.Carrera.carrera,
res.Horario.horario
);
return gmail(
mail.subject,
'lemuelhelonmarquezrosas@gmail.com',
// `${res.numeroCuenta}@pcpuma.acatlan.unam.mx`
mail.message
);
})
.then((res) =>
TercerSemestre.update(
{ deseaAsistir: true },
{ where: { idTercerSemestre } }
)
)
.then((res) => ({
message:
'Te has registrado correctamente, hemos mandado tu comprobante a tu correo pcpuma.',
}));
};
module.exports = registrar;
+23 -338
View File
@@ -3,34 +3,22 @@ const { Op } = require('sequelize');
const moment = require('moment');
const colors = require('colors');
const Carrera = require('./tablas/Carrera');
const CarreraHorario = require('./tablas/CarreraHorario');
const Grupo = require('./tablas/Grupo');
const GrupoHorario = require('./tablas/GrupoHorario');
const AlumnoHorario = require('./tablas/AlumnoHorario');
const Horario = require('./tablas/Horario');
const PrimerSemestre = require('./tablas/PrimerSemestre');
const TercerSemestre = require('./tablas/TercerSemestre');
const Alumno = require('./tablas/Alumno');
const drop = async () => {
console.log('\nPaso 1) Desinstalando la db.'.bold.blue);
await TercerSemestre.drop();
console.log('La tabla TercerSemestre se desinstalo correctamente.'.magenta);
await PrimerSemestre.drop();
console.log('La tabla PrimerSemestre se desinstalo correctamente.'.magenta);
await GrupoHorario.drop();
console.log('La tabla GrupoHorario se desinstalo correctamente.'.magenta);
await CarreraHorario.drop();
console.log('La tabla CarreraHorario se desinstalo correctamente.'.magenta);
await Grupo.drop();
console.log('La tabla Grupo se desinstalo correctamente.'.magenta);
await AlumnoHorario.drop();
console.log('La tabla AlumnoHorario se desinstalo correctamente.'.magenta);
await Horario.drop();
console.log('La tabla Horario se desinstalo correctamente.'.magenta);
await Alumno.drop();
console.log('La tabla Alumno se desinstalo correctamente.'.magenta);
await Carrera.drop();
console.log('La tabla Carrera se desinstalo correctamente.'.magenta);
};
@@ -41,258 +29,38 @@ const sync = async () => {
await Carrera.sync();
console.log('La tabla Carrera se instalo correctamente.'.magenta);
await Alumno.sync();
console.log('La tabla Alumno se instalo correctamente.'.magenta);
await Horario.sync();
console.log('La tabla Horario se instalo correctamente.'.magenta);
await Grupo.sync();
console.log('La tabla Grupo se instalo correctamente.'.magenta);
await CarreraHorario.sync();
console.log('La tabla CarreraHorario se instalo correctamente.'.magenta);
await GrupoHorario.sync();
console.log('La tabla GrupoHorario se instalo correctamente.'.magenta);
await PrimerSemestre.sync();
console.log('La tabla PrimerSemestre se instalo correctamente.'.magenta);
await TercerSemestre.sync();
console.log('La tabla TercerSemestre se instalo correctamente.'.magenta);
};
const data = [
{
carrera: 'ACTUARÍA',
matutino: 4,
despertino: 3,
horarioAsignado: { dia: '2021/08/12', horaInicio: '08:00' },
horariosAsignados: [{ dia: '2021/08/06', horaInicio: '08:00', turnos: 7 }],
},
{
carrera: 'ARQUITECTURA',
matutino: 4,
despertino: 3,
horarioAsignado: { dia: '2021/08/10', horaInicio: '10:40' },
horariosAsignados: [{ dia: '2021/08/03', horaInicio: '10:40', turnos: 7 }],
},
{
carrera: 'CIENCIAS POLÍTICAS Y ADMON. PÚBLICA',
matutino: 3,
despertino: 2,
horarioAsignado: { dia: '2021/08/12', horaInicio: '13:00' },
horariosAsignados: [{ dia: '2021/08/06', horaInicio: '13:00', turnos: 5 }],
},
{
carrera: 'COMUNICACIÓN',
matutino: 4,
despertino: 4,
horarioAsignado: { dia: '2021/08/11', horaInicio: '08:00' },
horariosAsignados: [{ dia: '2021/08/04', horaInicio: '08:00', turnos: 8 }],
},
{
carrera: 'DERECHO',
matutino: 9,
despertino: 9,
horarioAsignado: { dia: '2021/08/09', horaInicio: '08:00' },
horariosAsignados: [{ dia: '2021/08/02', horaInicio: '08:00', turnos: 18 }],
},
{
carrera: 'DISEÑO GRÁFICO',
matutino: 4,
despertino: 4,
horarioAsignado: { dia: '2021/08/10', horaInicio: '08:00' },
horariosAsignados: [{ dia: '2021/08/03', horaInicio: '08:00', turnos: 8 }],
},
{
carrera: 'ECONOMÍA',
matutino: 3,
despertino: 2,
horarioAsignado: { dia: '2021/08/13', horaInicio: '08:00' },
horariosAsignados: [
{ dia: '2021/08/04', horaInicio: '15:20', turnos: 1 },
{ dia: '2021/08/05', horaInicio: '08:00', turnos: 4 },
],
},
{
carrera: 'ENSEÑANZA DE INGLÉS',
matutino: 1,
despertino: 1,
horarioAsignado: { dia: '2021/08/11', horaInicio: '15:00' },
horariosAsignados: [{ dia: '2021/08/04', horaInicio: '15:00', turnos: 1 }],
},
{
carrera: 'FILOSOFÍA',
matutino: 1,
despertino: 1,
horarioAsignado: { dia: '2021/08/11', horaInicio: '12:40' },
horariosAsignados: [{ dia: '2021/08/04', horaInicio: '12:40', turnos: 2 }],
},
{
carrera: 'HISTORIA',
matutino: 2,
despertino: 1,
horarioAsignado: { dia: '2021/08/11', horaInicio: '14:00' },
horariosAsignados: [{ dia: '2021/08/04', horaInicio: '14:00', turnos: 3 }],
},
{
carrera: 'INGENIERÍA CIVIL',
matutino: 3,
despertino: 2,
horarioAsignado: { dia: '2021/08/09', horaInicio: '14:00' },
horariosAsignados: [{ dia: '2021/08/02', horaInicio: '14:00', turnos: 5 }],
},
{
carrera: 'LENGUA Y LITERATURA HISPÁNICAS',
matutino: 1,
despertino: 1,
horarioAsignado: { dia: '2021/08/11', horaInicio: '13:20' },
horariosAsignados: [{ dia: '2021/08/04', horaInicio: '13:20', turnos: 2 }],
},
{
carrera: 'MATEMÁTICAS. APL. Y COMP. (1999)',
matutino: 4,
despertino: 4,
horarioAsignado: { dia: '2021/08/12', horaInicio: '10:20' },
horariosAsignados: [{ dia: '2021/08/06', horaInicio: '10:20', turnos: 8 }],
},
{
carrera: 'PEDAGOGÍA',
matutino: 4,
despertino: 2,
horarioAsignado: { dia: '2021/08/11', horaInicio: '10:40' },
horariosAsignados: [{ dia: '2021/08/04', horaInicio: '10:40', turnos: 6 }],
},
{
carrera: 'RELACIONES INTERNACIONALES',
matutino: 3,
despertino: 3,
horarioAsignado: { dia: '2021/08/10', horaInicio: '13:00' },
horariosAsignados: [{ dia: '2021/08/03', horaInicio: '13:00', turnos: 6 }],
},
{
carrera: 'SOCIOLOGÍA',
matutino: 2,
despertino: 2,
horarioAsignado: { dia: '2021/08/13', horaInicio: '09:40' },
horariosAsignados: [
{ dia: '2021/08/03', horaInicio: '15:00', turnos: 2 },
{ dia: '2021/08/06', horaInicio: '14:40', turnos: 2 },
],
},
// {
// carrera: 'DERECHO (SUA)',
// matutino: 0,
// despertino: 0,
// horarioAsignado:{dia:'',horaInicio:''}
// },
// {
// carrera: 'ENSEÑANZA DE ESPAÑOL(LENG EXTRANJERA)SUA',
// matutino: 0,
// despertino: 0,
// horarioAsignado:{dia:'',horaInicio:''}
// },
// {
// carrera: 'ENSEÑANZA DE FRANCES(LENG EXTRANJERA)SUA',
// matutino: 0,
// despertino: 0,
// horarioAsignado:{dia:'',horaInicio:''}
// },
// {
// carrera: 'ENSEÑANZA DE INGLES (LENG EXTRANJERA)SUA',
// matutino: 0,
// despertino: 0,
// horarioAsignado:{dia:'',horaInicio:''}
// },
// {
// carrera: 'ENSEÑANZA DE ITALIANO(LENG EXTRANJ.)SUA',
// matutino: 0,
// despertino: 0,
// horarioAsignado:{dia:'',horaInicio:''}
// },
// {
// carrera: 'RELACIONES INTERNACIONALES (SUA)',
// matutino: 0,
// despertino: 0,
// horarioAsignado:{dia:'',horaInicio:''}
// },
];
const dataCarrera = async () => {
console.log('\nPaso 3) Instalando catalogo Carrera.'.bold.blue);
for (let i = 0; i < data.length; i++) {
await Carrera.create({ carrera: data[i].carrera });
console.log(
`Se agrego la carrera ${data[i].carrera} correctamente.`.magenta
);
}
};
const dataGrupo = async () => {
console.log('\nPaso 4) Instalando catalogo Grupo.'.bold.blue);
for (let i = 0; i < data.length; i++) {
for (let j = 1; j <= data[i].matutino; j++) {
const grupo = `110${j}`;
await Grupo.create({ grupo, idCarrera: i + 1 });
console.log(
`Se agrego el grupo ${grupo} a la carrera ${data[i].carrera} correctamente.`
.magenta
);
}
console.log();
for (let j = 1; j <= data[i].despertino; j++) {
const grupo = `115${j}`;
await Grupo.create({ grupo, idCarrera: i + 1 });
console.log(
`Se agrego el grupo ${grupo} a la carrera ${data[i].carrera} correctamente.`
.magenta
);
}
console.log();
for (let j = 1; j <= data[i].matutino; j++) {
const grupo = `220${j}`;
await Grupo.create({ grupo, idCarrera: i + 1 });
console.log(
`Se agrego el grupo ${grupo} a la carrera ${data[i].carrera} correctamente.`
.magenta
);
}
console.log();
for (let j = 1; j <= data[i].despertino; j++) {
const grupo = `225${j}`;
await Grupo.create({ grupo, idCarrera: i + 1 });
console.log(
`Se agrego el grupo ${grupo} a la carrera ${data[i].carrera} correctamente.`
.magenta
);
}
console.log('\n');
}
await AlumnoHorario.sync();
console.log('La tabla AlumnoHorario se instalo correctamente.'.magenta);
};
const dataHorario = async () => {
const diaFin = 13;
const diaInicio = 2;
const diaInicio = 16;
const diaFin = 22;
console.log('\nPaso 5) Instalando catalogo Horario.'.bold.blue);
console.log('\nPaso 3) Instalando catalogo Horario.'.bold.blue);
for (let i = diaInicio; i <= diaFin; i++) {
const dia = `2021/08/${i < 10 ? '0' + i : i}`;
const horaFin = 15;
const minutoFin = 20;
let horaInicio = 8;
const dia = `2021/11/${i < 10 ? '0' + i : i}`;
const horaFin = 17;
const minutoFin = 0;
let horaInicio = 10;
let minutoInicio = 0;
let parar = false;
let turno = 'V';
if (i === 7 || i === 8) continue;
if (i === 20 || i === 21) continue;
while (!parar) {
const hora = `${horaInicio < 10 ? '0' + horaInicio : horaInicio}:${
minutoInicio < 10 ? '0' + minutoInicio : minutoInicio
}`;
await Horario.create({ horario: `${dia} ${hora}` });
if (horaInicio === 13 && minutoInicio === 40) turno = 'M';
await Horario.create({ horario: `${dia} ${hora}`, turno });
console.log(`Se agrego el horario ${dia} ${hora} correctamente.`.magenta);
if (horaInicio === horaFin && minutoInicio === minutoFin) parar = true;
else {
@@ -306,93 +74,10 @@ const dataHorario = async () => {
}
};
const dataGrupoHorario = async () => {
console.log('\nPaso 6) Instalando catalogo GrupoHorario.'.bold.blue);
for (let i = 0; i < data.length; i++) {
const gruposCarrera = await Grupo.findAll({
where: { grupo: { [Op.like]: '22%' }, idCarrera: i + 1 },
});
let idHorario = await Horario.findOne({
where: {
horario: new Date(
`${data[i].horarioAsignado.dia} ${data[i].horarioAsignado.horaInicio}`
),
},
}).then((res) => res.idHorario);
for (let j = 0; j < gruposCarrera.length; j++) {
await GrupoHorario.create({
idHorario,
idGrupo: gruposCarrera[j].idGrupo,
})
.then((res) =>
GrupoHorario.findOne({
where: { idGrupoHorario: res.idGrupoHorario },
include: [
{ model: Grupo, include: [{ model: Carrera }] },
{ model: Horario },
],
})
)
.then((res) => {
console.log(
`Se le asigno al grupo ${res.Grupo.grupo} de la carrera ${
res.Grupo.Carrera.carrera
} el horario ${moment(res.Horario.horario).format()}`.magenta
);
idHorario++;
});
}
console.log();
}
};
const dataCarreraHorario = async () => {
console.log('\nPaso 7) Instalando catalogo CarreraHorario.'.bold.blue);
for (let i = 0; i < data.length; i++) {
for (let j = 0; j < data[i].horariosAsignados.length; j++) {
let idHorario = await Horario.findOne({
where: {
horario: new Date(
`${data[i].horariosAsignados[j].dia} ${data[i].horariosAsignados[j].horaInicio}`
),
},
}).then((res) => res.idHorario);
for (let k = 0; k < data[i].horariosAsignados[j].turnos; k++) {
await CarreraHorario.create({
idHorario,
idCarrera: i + 1,
})
.then((res) =>
CarreraHorario.findOne({
where: { idCarreraHorario: res.idCarreraHorario },
include: [{ model: Carrera }, { model: Horario }],
})
)
.then((res) => {
console.log(
`Se le asigno a la carrera ${
res.Carrera.carrera
} el horario ${moment(res.Horario.horario).format()}`.magenta
);
idHorario++;
});
}
}
console.log();
}
};
const exe = async () => {
await drop();
await sync();
await dataCarrera();
await dataGrupo();
await dataHorario();
await dataGrupoHorario();
await dataCarreraHorario();
console.log(
'\nSe ha instalado exitosamente la base de datos.\n'.underline.bold.green
@@ -2,30 +2,35 @@ const { DataTypes, Model } = require('sequelize');
const sequelize = require('../../config/sequelize.conf');
const Carrera = require('./Carrera');
class Grupo extends Model {}
Grupo.init(
class Alumno extends Model {}
Alumno.init(
{
idGrupo: {
idAlumno: {
type: DataTypes.INTEGER,
primaryKey: true,
allowNull: false,
unique: true,
autoIncrement: true,
},
grupo: {
type: DataTypes.STRING(4),
numeroCuenta: {
type: DataTypes.STRING(10),
allowNull: false,
unique: true,
},
turno: {
type: DataTypes.STRING(1),
allowNull: false,
},
},
{
sequelize,
modelName: 'Grupo',
tableName: 'grupo',
modelName: 'Alumno',
tableName: 'alumno',
timestamps: false,
}
);
Grupo.belongsTo(Carrera, {
Alumno.belongsTo(Carrera, {
foreignKey: {
name: 'idCarrera',
type: DataTypes.INTEGER,
@@ -33,4 +38,4 @@ Grupo.belongsTo(Carrera, {
},
});
module.exports = Grupo;
module.exports = Alumno;
@@ -1,12 +1,12 @@
const { DataTypes, Model } = require('sequelize');
const sequelize = require('../../config/sequelize.conf');
const Alumno = require('./Alumno');
const Horario = require('./Horario');
const Grupo = require('./Grupo');
class GrupoHorario extends Model {}
GrupoHorario.init(
class AlumnoHorario extends Model {}
AlumnoHorario.init(
{
idGrupoHorario: {
idAlumnoHorario: {
type: DataTypes.INTEGER,
primaryKey: true,
allowNull: false,
@@ -16,13 +16,13 @@ GrupoHorario.init(
},
{
sequelize,
modelName: 'GrupoHorario',
tableName: 'grupo_horario',
modelName: 'AlumnoHorario',
tableName: 'alumno_horario',
timestamps: false,
}
);
GrupoHorario.belongsTo(Horario, {
AlumnoHorario.belongsTo(Horario, {
foreignKey: {
name: 'idHorario',
type: DataTypes.INTEGER,
@@ -30,12 +30,12 @@ GrupoHorario.belongsTo(Horario, {
},
});
GrupoHorario.belongsTo(Grupo, {
AlumnoHorario.belongsTo(Alumno, {
foreignKey: {
name: 'idGrupo',
name: 'idAlumno',
type: DataTypes.INTEGER,
allowNull: false,
},
});
module.exports = GrupoHorario;
module.exports = AlumnoHorario;
-41
View File
@@ -1,41 +0,0 @@
const { DataTypes, Model } = require('sequelize');
const sequelize = require('../../config/sequelize.conf');
const Carrera = require('./Carrera');
const Horario = require('./Horario');
class CarreraHorario extends Model {}
CarreraHorario.init(
{
idCarreraHorario: {
type: DataTypes.INTEGER,
primaryKey: true,
allowNull: false,
unique: true,
autoIncrement: true,
},
},
{
sequelize,
modelName: 'CarreraHorario',
tableName: 'carrera_horario',
timestamps: false,
}
);
CarreraHorario.belongsTo(Horario, {
foreignKey: {
name: 'idHorario',
type: DataTypes.INTEGER,
allowNull: false,
},
});
CarreraHorario.belongsTo(Carrera, {
foreignKey: {
name: 'idCarrera',
type: DataTypes.INTEGER,
allowNull: false,
},
});
module.exports = CarreraHorario;
+4
View File
@@ -15,6 +15,10 @@ Horario.init(
type: DataTypes.DATE,
allowNull: false,
},
turno: {
type: DataTypes.STRING(1),
allowNull: false,
},
},
{
sequelize,
-61
View File
@@ -1,61 +0,0 @@
const { DataTypes, Model } = require('sequelize');
const sequelize = require('../../config/sequelize.conf');
const Horario = require('./Horario');
const Grupo = require('./Grupo');
class PrimerSemestre extends Model {}
PrimerSemestre.init(
{
idPrimerSemestre: {
type: DataTypes.INTEGER,
primaryKey: true,
allowNull: false,
unique: true,
autoIncrement: true,
},
numeroCuenta: {
type: DataTypes.STRING(10),
allowNull: false,
unique: true,
},
nombre: {
type: DataTypes.STRING(70),
allowNull: false,
},
correo: {
type: DataTypes.STRING(60),
allowNull: false,
},
asistio: {
type: DataTypes.BOOLEAN,
allowNull: true,
defaultValue: null,
},
},
{
sequelize,
modelName: 'PrimerSemestre',
tableName: 'primer_semestre',
timestamps: false,
}
);
PrimerSemestre.belongsTo(Grupo, {
foreignKey: {
name: 'idGrupo',
type: DataTypes.INTEGER,
allowNull: true,
defaultValue: null,
},
});
PrimerSemestre.belongsTo(Horario, {
foreignKey: {
name: 'idHorario',
type: DataTypes.INTEGER,
allowNull: true,
defaultValue: null,
},
});
module.exports = PrimerSemestre;
-51
View File
@@ -1,51 +0,0 @@
const { DataTypes, Model } = require('sequelize');
const sequelize = require('../../config/sequelize.conf');
const Grupo = require('./Grupo');
class TercerSemestre extends Model {}
TercerSemestre.init(
{
idTercerSemestre: {
type: DataTypes.INTEGER,
primaryKey: true,
allowNull: false,
unique: true,
autoIncrement: true,
},
numeroCuenta: {
type: DataTypes.STRING(10),
allowNull: false,
unique: true,
},
nombre: {
type: DataTypes.STRING(70),
allowNull: false,
},
deseaAsistir: {
type: DataTypes.BOOLEAN,
allowNull: true,
defaultValue: null,
},
asistio: {
type: DataTypes.BOOLEAN,
allowNull: true,
defaultValue: null,
},
},
{
sequelize,
modelName: 'TercerSemestre',
tableName: 'tercer_semestre',
timestamps: false,
}
);
TercerSemestre.belongsTo(Grupo, {
foreignKey: {
name: 'idGrupo',
type: DataTypes.INTEGER,
allowNull: false,
},
});
module.exports = TercerSemestre;
@@ -1,9 +1,10 @@
const express = require('express');
const app = express();
const route = '/grupo';
const controllerPath = '../controller/Grupo';
const route = '/tercer_semestre';
const controllerPath = '../controller/TercerSemestre';
const get = require(`${controllerPath}/get`);
// GET
app.get(`${route}`, (req, res) => {
return get(req.query)
.then((data) => {
+29
View File
@@ -0,0 +1,29 @@
const express = require('express');
const app = express();
const route = '/grupo_horario';
const controllerPath = '../controller/GrupoHorario';
// const horariosDia = require(`${controllerPath}/horariosDia`);
// const monitor = require(`${controllerPath}/monitor`);
// // GET
// app.get(`${route}/horarios_dia`, (req, res) => {
// return horariosDia(req.body)
// .then((data) => {
// res.status(200).json(data);
// })
// .catch((err) => {
// res.status(400).json({ message: err.message });
// });
// });
// app.get(`${route}/monitor`, (req, res) => {
// return monitor(req.body)
// .then((data) => {
// res.status(200).json(data);
// })
// .catch((err) => {
// res.status(400).json({ message: err.message });
// });
// });
module.exports = app;
-17
View File
@@ -1,17 +0,0 @@
const express = require('express');
const app = express();
const route = '/carrera';
const controllerPath = '../controller/Carrera';
const get = require(`${controllerPath}/get`);
app.get(`${route}`, (req, res) => {
return get()
.then((data) => {
res.status(200).json(data);
})
.catch((err) => {
res.status(400).json({ message: err.message });
});
});
module.exports = app;
-40
View File
@@ -1,40 +0,0 @@
const express = require('express');
const app = express();
const route = '/carrera_horario';
const controllerPath = '../controller/CarreraHorario';
const get = require(`${controllerPath}/get`);
const horariosDia = require(`${controllerPath}/horariosDia`);
const monitor = require(`${controllerPath}/monitor`);
// 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 });
});
});
app.get(`${route}/horarios_dia`, (req, res) => {
return horariosDia(req.body)
.then((data) => {
res.status(200).json(data);
})
.catch((err) => {
res.status(400).json({ message: err.message });
});
});
app.get(`${route}/monitor`, (req, res) => {
return monitor(req.body)
.then((data) => {
res.status(200).json(data);
})
.catch((err) => {
res.status(400).json({ message: err.message });
});
});
module.exports = app;
-29
View File
@@ -1,29 +0,0 @@
const express = require('express');
const app = express();
const route = '/grupo_horario';
const controllerPath = '../controller/GrupoHorario';
const horariosDia = require(`${controllerPath}/horariosDia`);
const monitor = require(`${controllerPath}/monitor`);
// GET
app.get(`${route}/horarios_dia`, (req, res) => {
return horariosDia(req.body)
.then((data) => {
res.status(200).json(data);
})
.catch((err) => {
res.status(400).json({ message: err.message });
});
});
app.get(`${route}/monitor`, (req, res) => {
return monitor(req.body)
.then((data) => {
res.status(200).json(data);
})
.catch((err) => {
res.status(400).json({ message: err.message });
});
});
module.exports = app;
-64
View File
@@ -1,64 +0,0 @@
const express = require('express');
const app = express();
const route = '/primer_semestre';
const controllerPath = '../controller/PrimerSemestre';
const alumnosCarrera = require(`${controllerPath}/alumnosCarrera`);
const asistencia = require(`${controllerPath}/asistencia`);
const asistentes = require(`${controllerPath}/asistentes`);
const csv = require(`${controllerPath}/csv`);
const registrar = require(`${controllerPath}/registrar`);
// POST
app.post(`${route}/csv`, (req, res) => {
return csv(req.body)
.then((data) => {
res.download(data);
})
.catch((err) => {
res.status(400).json({ message: err.message });
});
});
app.post(`${route}/registrar`, (req, res) => {
return registrar(req.body)
.then((data) => {
res.status(200).json(data);
})
.catch((err) => {
res.status(400).json({ message: err.message });
});
});
// PUT
app.put(`${route}/asistencia`, (req, res) => {
return asistencia(req.body)
.then((data) => {
res.status(200).json(data);
})
.catch((err) => {
res.status(400).json({ message: err.message });
});
});
// GET
app.get(`${route}/asistentes`, (req, res) => {
return asistentes(req.query)
.then((data) => {
res.status(200).json(data);
})
.catch((err) => {
res.status(400).json({ message: err.message });
});
});
app.get(`${route}/alumnos_carrera`, (req, res) => {
return alumnosCarrera(req.query)
.then((data) => {
res.status(200).json(data);
})
.catch((err) => {
res.status(400).json({ message: err.message });
});
});
module.exports = app;
-75
View File
@@ -1,75 +0,0 @@
const express = require('express');
const app = express();
const route = '/tercer_semestre';
const controllerPath = '../controller/TercerSemestre';
const alumnosCarrera = require(`${controllerPath}/alumnosCarrera`);
const asistencia = require(`${controllerPath}/asistencia`);
const asistentes = require(`${controllerPath}/asistentes`);
const csv = require(`${controllerPath}/csv`);
const get = require(`${controllerPath}/get`);
const registrar = require(`${controllerPath}/registrar`);
// POST
app.post(`${route}/csv`, (req, res) => {
return csv(req.body)
.then((data) => {
res.download(data);
})
.catch((err) => {
res.status(400).json({ message: err.message });
});
});
//PUT
app.put(`${route}/registrar`, (req, res) => {
return registrar(req.body)
.then((data) => {
res.status(200).json(data);
})
.catch((err) => {
res.status(400).json({ message: err.message });
});
});
app.put(`${route}/asistencia`, (req, res) => {
return asistencia(req.body)
.then((data) => {
res.status(200).json(data);
})
.catch((err) => {
res.status(400).json({ message: err.message });
});
});
// 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 });
});
});
app.get(`${route}/asistentes`, (req, res) => {
return asistentes(req.query)
.then((data) => {
res.status(200).json(data);
})
.catch((err) => {
res.status(400).json({ message: err.message });
});
});
app.get(`${route}/alumnos_carrera`, (req, res) => {
return alumnosCarrera(req.query)
.then((data) => {
res.status(200).json(data);
})
.catch((err) => {
res.status(400).json({ message: err.message });
});
});
module.exports = app;
+2 -6
View File
@@ -1,11 +1,7 @@
const express = require('express');
const app = express();
app.use(require('./Carrera'));
app.use(require('./CarreraHorario'));
app.use(require('./Grupo'));
app.use(require('./GrupoHorario'));
app.use(require('./PrimerSemestre'));
app.use(require('./TercerSemestre'));
app.use(require('./Alumno'));
app.use(require('./AlumnoHorario'));
module.exports = app;