Skip to content

Commit

Permalink
Book resource customization + add additional findByPublicationYear me…
Browse files Browse the repository at this point in the history
…thod
  • Loading branch information
aureamunoz committed Oct 2, 2023
1 parent a3621ff commit 664ff90
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
26 changes: 26 additions & 0 deletions src/main/java/org/acme/BookRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.acme;

import io.quarkus.hibernate.orm.rest.data.panache.PanacheEntityResource;
import io.quarkus.rest.data.panache.MethodProperties;
import io.quarkus.rest.data.panache.ResourceProperties;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;

import java.util.Collections;
import java.util.List;

@ResourceProperties(path = "books")
public interface BookRepository extends PanacheEntityResource<Book, Long> {

@MethodProperties(exposed = false)
boolean delete(Long id);

@GET
@Path("/year/{year}")
@Produces("application/json")
default List<Book> findByPublicationYear(@PathParam("year") Integer year) {
return Book.find("publicationYear = :year", Collections.singletonMap("year", year)).list();
}
}
6 changes: 0 additions & 6 deletions src/main/java/org/acme/BookResource.java

This file was deleted.

0 comments on commit 664ff90

Please sign in to comment.