monitor, asistencia, asistentes
This commit is contained in:
+2
-8
@@ -1,16 +1,10 @@
|
||||
const moment = require('moment');
|
||||
const { Op } = require('sequelize');
|
||||
const helperPath = '../../helper';
|
||||
const helper = require(`${helperPath}/helper`);
|
||||
const encriptar = require(`${helperPath}/encriptar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const CarreraHorario = require(`${dbPath}/CarreraHorario`);
|
||||
const Grupo = require(`${dbPath}/Grupo`);
|
||||
const Horario = require(`${dbPath}/Horario`);
|
||||
const PrimerSemestre = require(`${dbPath}/PrimerSemestre`);
|
||||
|
||||
const get = async (body) => {
|
||||
const monitor = async (body) => {
|
||||
return CarreraHorario.findAll({
|
||||
include: [{ model: Horario }, { model: Carrera }],
|
||||
order: ['idHorario'],
|
||||
@@ -28,4 +22,4 @@ const get = async (body) => {
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = get;
|
||||
module.exports = monitor;
|
||||
@@ -0,0 +1,24 @@
|
||||
const helperPath = '../../helper';
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const PrimerSemestre = require(`${dbPath}/PrimerSemestre`);
|
||||
|
||||
const asistencia = async (body) => {
|
||||
const idPrimerSemestre = validar.validarId(body.idPrimerSemestre);
|
||||
|
||||
return PrimerSemestre.findOne({ where: { idPrimerSemestre } })
|
||||
.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 PrimerSemestre.update(
|
||||
{ asistio: true },
|
||||
{ where: { idPrimerSemestre } }
|
||||
);
|
||||
})
|
||||
.then((res) => ({
|
||||
message: 'Se registro correctamente la asistencia de este alumno.',
|
||||
}));
|
||||
};
|
||||
|
||||
module.exports = asistencia;
|
||||
@@ -0,0 +1,17 @@
|
||||
const helperPath = '../../helper';
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const Grupo = require(`${dbPath}/Grupo`);
|
||||
const PrimerSemestre = require(`${dbPath}/PrimerSemestre`);
|
||||
|
||||
const asistentes = async (body) => {
|
||||
const idHorario = validar.validarId(body.idHorario);
|
||||
|
||||
return PrimerSemestre.findAll({
|
||||
where: { idHorario },
|
||||
include: [{ model: Grupo, include: [{ model: Carrera }] }],
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = asistentes;
|
||||
@@ -1,5 +1,5 @@
|
||||
const { convertArrayToCSV } = require('convert-array-to-csv');
|
||||
const moment = require('moment');
|
||||
const { convertArrayToCSV } = require('convert-array-to-csv');
|
||||
const helperPath = '../../helper';
|
||||
const helper = require(`${helperPath}/helper`);
|
||||
const encriptar = require(`${helperPath}/encriptar`);
|
||||
@@ -9,7 +9,7 @@ const Grupo = require(`${dbPath}/Grupo`);
|
||||
const Horario = require(`${dbPath}/Horario`);
|
||||
const PrimerSemestre = require(`${dbPath}/PrimerSemestre`);
|
||||
|
||||
const get = async (body) => {
|
||||
const csv = async (body) => {
|
||||
const path = `server/uploads/primer_semestre.csv`;
|
||||
const data = [];
|
||||
|
||||
@@ -54,4 +54,4 @@ const get = async (body) => {
|
||||
.then((res) => path);
|
||||
};
|
||||
|
||||
module.exports = get;
|
||||
module.exports = csv;
|
||||
|
||||
@@ -9,7 +9,7 @@ const Horario = require(`${dbPath}/Horario`);
|
||||
const Grupo = require(`${dbPath}/Grupo`);
|
||||
const PrimerSemestre = require(`${dbPath}/PrimerSemestre`);
|
||||
|
||||
const get = async (body) => {
|
||||
const registrar = async (body) => {
|
||||
const idCarrera = validar.validarId(body.idCarrera);
|
||||
const idGrupo = validar.validarId(body.idGrupo);
|
||||
const idHorario = validar.validarId(body.idHorario);
|
||||
@@ -82,4 +82,4 @@ const get = async (body) => {
|
||||
}));
|
||||
};
|
||||
|
||||
module.exports = get;
|
||||
module.exports = registrar;
|
||||
|
||||
@@ -3,7 +3,9 @@ const app = express();
|
||||
const route = '/carrera_horario';
|
||||
const controllerPath = '../controller/CarreraHorario';
|
||||
const get = require(`${controllerPath}/get`);
|
||||
const monitor = require(`${controllerPath}/monitor`);
|
||||
|
||||
// GET
|
||||
app.get(`${route}`, (req, res) => {
|
||||
return get(req.query)
|
||||
.then((data) => {
|
||||
@@ -14,4 +16,14 @@ app.get(`${route}`, (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
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;
|
||||
|
||||
@@ -3,7 +3,6 @@ const app = express();
|
||||
const route = '/primer_semestre';
|
||||
const controllerPath = '../controller/PrimerSemestre';
|
||||
const csv = require(`${controllerPath}/csv`);
|
||||
const graficas = require(`${controllerPath}/graficas`);
|
||||
const registrar = require(`${controllerPath}/registrar`);
|
||||
|
||||
// POST
|
||||
@@ -28,14 +27,5 @@ app.post(`${route}/registrar`, (req, res) => {
|
||||
});
|
||||
|
||||
// GET
|
||||
app.get(`${route}/graficas`, (req, res) => {
|
||||
return graficas(req.body)
|
||||
.then((data) => {
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = app;
|
||||
|
||||
Reference in New Issue
Block a user