Cambios en el back de inscripciones

This commit is contained in:
santiago
2025-07-28 15:33:09 -06:00
parent 2d7cf996d2
commit 58368a6929
16 changed files with 442 additions and 10 deletions
@@ -0,0 +1,38 @@
const { buscarProfesorPorNumero } = require('../../config/mariadb.conf');
const Inscripcion = require('../../db/tablas/Inscripcion');
async function buscarProfesor(req, res) {
const { numeroTrabajador } = req.params;
try {
// Borrar esta linea de codigo
//console.log('Buscando profesor con RFC:', numeroTrabajador);
const profesor = await buscarProfesorPorNumero(numeroTrabajador);
if (!profesor) {
return res.status(404).json({ message: 'Profesor no encontrado' });
}
// Verificar si existe ya en la tabla de incripcion
const existeIncripcion = await Inscripcion.findOne({
where: {
idUsuario: profesor.idUsuario
}
});
if (existeIncripcion) {
return res.status(409).json({
//yaInscrito: true,
message: 'El usuario ya está inscrito.',
});
}
res.status(200).json(profesor); // { nombre, correo }
} catch (error) {
res.status(500).json({ message: error.message });
}
}
module.exports = buscarProfesor;