diff --git a/bookstore/src/main/java/com/fjordtek/bookstore/model/BookRepository.java b/bookstore/src/main/java/com/fjordtek/bookstore/model/BookRepository.java index 50d776e..2a4ce1c 100644 --- a/bookstore/src/main/java/com/fjordtek/bookstore/model/BookRepository.java +++ b/bookstore/src/main/java/com/fjordtek/bookstore/model/BookRepository.java @@ -8,14 +8,21 @@ import java.util.Optional; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.query.Param; import org.springframework.data.rest.core.annotation.RepositoryRestResource; +import org.springframework.data.rest.core.annotation.RestResource; -@RepositoryRestResource +@RepositoryRestResource( + path = "booklist", + itemResourceRel = "booklist", + exported = true + ) public interface BookRepository extends CrudRepository { @Override + @RestResource(exported = false) public Optional findById(Long id); - public List findByTitle(@Param("title") String title); + @RestResource(path = "title", rel = "title") + public List findByTitle(@Param("name") String title); /* Assume a single book with a single ISBN, or multiple books with possibly duplicate ISBNs? * For meanwhile, we have a UNIQUE constraint for ISBN values. If this policy changes, @@ -23,8 +30,10 @@ public interface BookRepository extends CrudRepository { * we return a single book. */ //public List findByIsbn(String isbn); + @RestResource(exported = false) public Book findByIsbn(String isbn); + @RestResource(exported = false) public boolean existsByIsbn(String isbn); } \ No newline at end of file diff --git a/bookstore/src/main/java/com/fjordtek/bookstore/model/CategoryRepository.java b/bookstore/src/main/java/com/fjordtek/bookstore/model/CategoryRepository.java index e818424..65cb322 100644 --- a/bookstore/src/main/java/com/fjordtek/bookstore/model/CategoryRepository.java +++ b/bookstore/src/main/java/com/fjordtek/bookstore/model/CategoryRepository.java @@ -5,9 +5,18 @@ package com.fjordtek.bookstore.model; import java.util.List; import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; +import org.springframework.data.rest.core.annotation.RestResource; +@RepositoryRestResource( + path = "categories", + itemResourceRel = "categories", + exported = true + ) public interface CategoryRepository extends CrudRepository { - public List findByName(String name); + @RestResource(path = "category", rel = "category") + public List findByName(@Param("name") String name); } \ No newline at end of file