casi terminada
This commit is contained in:
@@ -13,19 +13,29 @@ const cargaMasiva = async (file, body) => {
|
||||
.fromFile(path)
|
||||
.then(async (profesores) => {
|
||||
for (let i = 0; i < profesores.length; i++) {
|
||||
const resp = await Profesor.create({
|
||||
numeroTrabajador: profesores[i].numeroTrabajador,
|
||||
nombre: profesores[i].nombre,
|
||||
correo: `${profesores[i].numeroTrabajador}@pcpuma.acatlan.unam.mx`,
|
||||
adscripcion: profesores[i].adscripcion,
|
||||
let profesor = await Profesor.findOne({
|
||||
where: { numeroTrabajador: profesores[i].numeroTrabajador },
|
||||
});
|
||||
res.push(resp);
|
||||
let resp;
|
||||
|
||||
if (!profesor) {
|
||||
resp = await Profesor.create({
|
||||
numeroTrabajador: profesores[i].numeroTrabajador,
|
||||
nombre: profesores[i].nombre,
|
||||
correo: `${profesores[i].numeroTrabajador}@pcpuma.acatlan.unam.mx`,
|
||||
adscripcion: profesores[i].adscripcion,
|
||||
});
|
||||
}
|
||||
|
||||
profesor ? res.push(profesor) : res.push(resp);
|
||||
|
||||
await ProfesorPremiacion.create({
|
||||
idPremiacion,
|
||||
idProfesor: resp.idProfesor,
|
||||
idProfesor: profesor ? profesor.idProfesor : resp.idProfesor,
|
||||
numeroInvitados: null,
|
||||
numeroInvitadosDentro: null,
|
||||
});
|
||||
profesor = null;
|
||||
}
|
||||
await eliminarArchivo(path);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user