primera instancia de validador y carga del excel de usuarios, falta agregar las relaciones con las carreras y verificar los validadores

This commit is contained in:
Your Name
2025-06-13 17:54:38 -06:00
parent 8660c85b79
commit 4deb5ecf34
11 changed files with 2083 additions and 93 deletions
+34
View File
@@ -0,0 +1,34 @@
// src/excel/excel.controller.ts
import {
Controller,
Post,
UploadedFile,
UseInterceptors,
BadRequestException,
} from '@nestjs/common';
import { FileInterceptor } from '@nestjs/platform-express';
import { ExcelService } from './excel.service';
import { ExcelDocumentation } from './excel.documentation';
@Controller('excel')
export class ExcelController {
constructor(private readonly excelService: ExcelService) {}
@Post('verify')
@UseInterceptors(FileInterceptor('file'))
@ExcelDocumentation.verifyExcel()
async verifyExcel(@UploadedFile() file: Express.Multer.File) {
if (!file) throw new BadRequestException('Se requiere un archivo .xlsx');
const errors = await this.excelService.validateFile(file.buffer);
return { valid: errors.length === 0, errors };
}
@Post('load')
@UseInterceptors(FileInterceptor('file'))
@ExcelDocumentation.loadExcel()
async loadExcel(@UploadedFile() file: Express.Multer.File) {
if (!file) throw new BadRequestException('Se requiere un archivo .xlsx');
const result = await this.excelService.loadFile(file.buffer);
return result; // { inserted: X }
}
}