mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-13 00:48:49 +00:00
37 lines
941 B
Java
37 lines
941 B
Java
package com.imprimelibros.erp.paises;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.*;
|
|
|
|
@RestController
|
|
@RequestMapping("/api/paises")
|
|
public class PaisesController {
|
|
|
|
private final PaisesService paisesService;
|
|
|
|
public PaisesController(PaisesService paisesService) {
|
|
this.paisesService = paisesService;
|
|
}
|
|
|
|
/**
|
|
* Compatible con Select2 (AJAX):
|
|
* - Soporta parámetros opcionales:
|
|
* - q / term : texto a buscar
|
|
* - lang : ej. "es", "en" (si se omite usa Locale actual)
|
|
*
|
|
* Respuesta:
|
|
* { "results": [ { "id": "espania", "text": "España" }, ... ] }
|
|
*/
|
|
@GetMapping
|
|
public Map<String, Object> getPaises(
|
|
@RequestParam(value = "q", required = false) String q1,
|
|
@RequestParam(value = "term", required = false) String q2,
|
|
Locale locale) {
|
|
|
|
|
|
return paisesService.getForSelect(q1, q2, locale);
|
|
|
|
}
|
|
}
|