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.
51 lines
1.5 KiB
Java
51 lines
1.5 KiB
Java
|
1 month ago
|
package com.service.ingresantes.controller;
|
||
|
|
|
||
|
|
import com.service.ingresantes.entity.ResultadoExamen;
|
||
|
|
import com.service.ingresantes.service.ResultadoService;
|
||
|
|
import org.springframework.http.ResponseEntity;
|
||
|
|
import org.springframework.web.bind.annotation.*;
|
||
|
|
|
||
|
|
import java.util.List;
|
||
|
|
import java.util.Optional;
|
||
|
|
|
||
|
|
@RestController
|
||
|
|
@RequestMapping("/api/resultados")
|
||
|
|
@CrossOrigin("*")
|
||
|
|
public class ResultadoController {
|
||
|
|
|
||
|
|
private final ResultadoService resultadoService;
|
||
|
|
|
||
|
|
public ResultadoController(ResultadoService resultadoService) {
|
||
|
|
this.resultadoService = resultadoService;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Buscar resultado por DNI y proceso
|
||
|
|
@GetMapping("/{dni}/{procesoId}")
|
||
|
|
public ResponseEntity<?> obtenerResultado(
|
||
|
|
@PathVariable String dni,
|
||
|
|
@PathVariable Long procesoId) {
|
||
|
|
|
||
|
|
Optional<ResultadoExamen> resultado =
|
||
|
|
resultadoService.obtenerResultado(dni, procesoId);
|
||
|
|
|
||
|
|
if (resultado.isEmpty()) {
|
||
|
|
|
||
|
|
return ResponseEntity
|
||
|
|
.badRequest()
|
||
|
|
.body("No se encontró resultado para ese DNI y proceso");
|
||
|
|
}
|
||
|
|
|
||
|
|
return ResponseEntity.ok(resultado.get());
|
||
|
|
}
|
||
|
|
|
||
|
|
// Ranking del proceso
|
||
|
|
@GetMapping("/ranking/{procesoId}")
|
||
|
|
public ResponseEntity<List<ResultadoExamen>> ranking(
|
||
|
|
@PathVariable Long procesoId) {
|
||
|
|
|
||
|
|
List<ResultadoExamen> ranking =
|
||
|
|
resultadoService.obtenerRanking(procesoId);
|
||
|
|
|
||
|
|
return ResponseEntity.ok(ranking);
|
||
|
|
}
|
||
|
|
}
|