|
|
@ -2,12 +2,18 @@ package fr.uca.iut.controllers;
|
|
|
|
|
|
|
|
|
|
|
|
import fr.uca.iut.entities.Pokemong;
|
|
|
|
import fr.uca.iut.entities.Pokemong;
|
|
|
|
import fr.uca.iut.services.PokemongService;
|
|
|
|
import fr.uca.iut.services.PokemongService;
|
|
|
|
|
|
|
|
import fr.uca.iut.utils.StringUtils;
|
|
|
|
import jakarta.annotation.PostConstruct;
|
|
|
|
import jakarta.annotation.PostConstruct;
|
|
|
|
import jakarta.inject.Inject;
|
|
|
|
import jakarta.inject.Inject;
|
|
|
|
|
|
|
|
import jakarta.ws.rs.GET;
|
|
|
|
import jakarta.ws.rs.Path;
|
|
|
|
import jakarta.ws.rs.Path;
|
|
|
|
|
|
|
|
import jakarta.ws.rs.PathParam;
|
|
|
|
import jakarta.ws.rs.Produces;
|
|
|
|
import jakarta.ws.rs.Produces;
|
|
|
|
import jakarta.ws.rs.core.MediaType;
|
|
|
|
import jakarta.ws.rs.core.MediaType;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
@Path("/pokemong")
|
|
|
|
@Path("/pokemong")
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
public class PokemongController extends GenericController<Pokemong> {
|
|
|
|
public class PokemongController extends GenericController<Pokemong> {
|
|
|
@ -19,4 +25,23 @@ public class PokemongController extends GenericController<Pokemong> {
|
|
|
|
public void init() {
|
|
|
|
public void init() {
|
|
|
|
setService(pokemongService);
|
|
|
|
setService(pokemongService);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* REST endpoint to fetch Pokemong entities by nickname.
|
|
|
|
|
|
|
|
* The match is case-insensitive, ignores leading and trailing spaces, and can be a partial nickname.
|
|
|
|
|
|
|
|
* If the nickname is null or blank, an empty list is returned.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param nickname the nickname to search for in the database. Can be a partial nickname.
|
|
|
|
|
|
|
|
* @return List of Pokemong entities with a nickname matching the provided nickname. If no match is found, an empty list is returned.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@GET
|
|
|
|
|
|
|
|
@Path("/nickname/{nickname}")
|
|
|
|
|
|
|
|
public List<Pokemong> findByName(@PathParam("nickname") String nickname) {
|
|
|
|
|
|
|
|
return StringUtils.isBlankStringOrNull(nickname)
|
|
|
|
|
|
|
|
? new ArrayList<>()
|
|
|
|
|
|
|
|
: pokemongService.findByNickname(nickname.trim());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|