You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
996 B
Java

2 months ago
package com.service.ingresantes.controller;
import com.service.ingresantes.service.ExcelService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@RestController
@RequestMapping("/api/excel")
public class ExcelController {
private final ExcelService excelService;
public ExcelController(ExcelService excelService) {
this.excelService = excelService;
}
@PostMapping("/upload")
public ResponseEntity<String> uploadExcel(@RequestParam("file") MultipartFile file) {
try {
excelService.importarExcel(file);
return ResponseEntity.ok("Archivo subido y procesado correctamente!");
} catch (Exception e) {
return ResponseEntity.badRequest().body("Error al procesar el archivo: " + e.getMessage());
}
}
@GetMapping("/ping")
public String ping() {
return "API funcionando123456!";
}
}