inicio de la carga masiva de equipos
This commit is contained in:
parent
871f807954
commit
a60c817265
@ -24,12 +24,25 @@ export class UploadFileService {
|
|||||||
async createEquipos(file: Express.Multer.File, id_institucion: number) {
|
async createEquipos(file: Express.Multer.File, id_institucion: number) {
|
||||||
const path = `${file.destination}/${file.filename}`;
|
const path = `${file.destination}/${file.filename}`;
|
||||||
const institucion = await this.institucionService.findById(id_institucion);
|
const institucion = await this.institucionService.findById(id_institucion);
|
||||||
|
const errores: string[] = [];
|
||||||
|
|
||||||
if (!file) throw new BadRequestException('No se mando un archivo.');
|
if (!file) throw new BadRequestException('No se mando un archivo.');
|
||||||
csvtojson()
|
csvtojson()
|
||||||
.fromFile(path)
|
.fromFile(path)
|
||||||
.then(async (equipos) => {
|
.then(async (equipos) => {
|
||||||
for (let i = 0; i < equipos.length; i++) {}
|
for (let i = 0; i < equipos.length; i++) {
|
||||||
|
if(!equipos[i].modulo) errores.push(`${this.errorBase(i)} falta el campo modulo en el archivo`)
|
||||||
|
if(!equipos[i].carrito) errores.push(`${this.errorBase(i)} falta el campo carrito en el archivo`)
|
||||||
|
if(!equipos[i].tipo) errores.push(`${this.errorBase(i)} falta el campo tipo en el archivo`)
|
||||||
|
if(!equipos[i].equipo) errores.push(`${this.errorBase(i)} falta el campo equipo en el archivo`)
|
||||||
|
if(!equipos[i].numero_inventario) errores.push(`${this.errorBase(i)} falta el campo numero_inventario en el archivo`)
|
||||||
|
if(!equipos[i].numero_serie) errores.push(`${this.errorBase(i)} falta el campo numero_serie en el archivo`)
|
||||||
|
if(!equipos[i].modulo) errores.push(`${this.errorBase(i)} falta el campo modulo en el archivo`)
|
||||||
|
if(!equipos[i].entradas) errores.push(`${this.errorBase(i)} falta el campo entradas en el archivo`)
|
||||||
|
// faltan los programas
|
||||||
|
if(!equipos[i].programas) errores.push(`${this.errorBase(i)} falta el campo programas en el archivo`)
|
||||||
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user