api completa
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
const csv = require('csvtojson');
|
||||
const { eliminarArchivo } = require('../../helper/helper');
|
||||
const Profesor = require('../../db/tablas/Profesor');
|
||||
const { validarNumeroEntero } = require('../../helper/validar');
|
||||
const ProfesorPremiacion = require('../../db/tablas/profesorPremiacion');
|
||||
|
||||
const cargaMasiva = async (file) => {
|
||||
const cargaMasiva = async (file, body) => {
|
||||
const idPremiacion = validarNumeroEntero(body.idPremiacion);
|
||||
const path = `server/uploads/${file}`;
|
||||
let res = [];
|
||||
|
||||
@@ -15,15 +18,21 @@ const cargaMasiva = async (file) => {
|
||||
nombre: profesores[i].nombre,
|
||||
correo: `${profesores[i].numeroTrabajador}@pcpuma.acatlan.unam.mx`,
|
||||
adscripcion: profesores[i].adscripcion,
|
||||
})
|
||||
res.push(resp)
|
||||
});
|
||||
res.push(resp);
|
||||
await ProfesorPremiacion.create({
|
||||
idPremiacion,
|
||||
idProfesor: resp.idProfesor,
|
||||
numeroInvitados: null,
|
||||
numeroInvitadosDentro: null,
|
||||
});
|
||||
}
|
||||
await eliminarArchivo(path);
|
||||
});
|
||||
return {
|
||||
message: 'Se subió correctamente el archivo csv.',
|
||||
res
|
||||
res,
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = cargaMasiva;
|
||||
module.exports = cargaMasiva;
|
||||
|
||||
Reference in New Issue
Block a user