@DELETE @Path("/{id}") public Response deletarAnimal(@PathParam("id") int id) { Animal animal = AnimalDao.getById(id); try { AdocaoDao.deletePorAnimal(animal); AnuncioDao.deletePorAnimal(animal); AnimalDao.deleteAnimal(animal); } catch (Exception e) { String result = "Error: " + e.getMessage(); return Response.status(500).entity(result).build(); } String result = "Animal Deletado : " + animal.getNomeAdotivo(); return Response.status(200).entity(result).build(); }
@POST @Consumes("application/json") public Response criarAnimal(Animal animal) { try { AnimalDao.saveAnimal(animal); } catch (Exception e) { String result = "Error: " + e.getMessage(); return Response.status(500).entity(result).build(); } String result = "Animal Criado : " + animal.getNomeAdotivo(); return Response.status(200).entity(result).build(); }
@GET @Path("/{id}") @Produces("application/json") public Animal trazerAnimal(@PathParam("id") int id) { return AnimalDao.getById(id); }
@GET @Path("/disponiveis") @Produces("application/json") public List<Animal> trazerAnimaisDisponiveis() { return AnimalDao.getDisponiveis(); }
@GET @Path("/instituicao/{id}") @Produces("application/json") public List<Animal> trazerAnimaisPorInstituicao(@PathParam("id") int id) { return AnimalDao.getByInstituicao(id); }
@GET @Path("/todos") @Produces("application/json") public List<Animal> trazerAnimais() { return AnimalDao.getAnimais(); }