Browse Source

REST API: improve searching scheme

Signed-off-by: Pekka Helenius <fincer89@hotmail.com>
v0.0.2-alpha
Pekka Helenius 4 years ago
parent
commit
cccbaf56e5
2 changed files with 12 additions and 2 deletions
  1. +11
    -1
      bookstore/src/main/java/com/fjordtek/bookstore/model/AuthorRepository.java
  2. +1
    -1
      bookstore/src/main/java/com/fjordtek/bookstore/model/BookRepository.java

+ 11
- 1
bookstore/src/main/java/com/fjordtek/bookstore/model/AuthorRepository.java View File

@ -23,9 +23,19 @@ import org.springframework.data.rest.core.annotation.RestResource;
)
public interface AuthorRepository extends CrudRepository<Author,Long> {
@RestResource(path = "author", rel = "author")
@RestResource(path = "fullname", rel = "fullname")
public List<Author> findByFirstNameIgnoreCaseContainingAndLastNameIgnoreCaseContaining(
@Param("firstname") String firstName, @Param("lastname") String lastName
);
@RestResource(path = "firstname", rel = "firstname")
public List<Author> findByFirstNameIgnoreCaseContaining(
@Param("firstname") String firstName
);
@RestResource(path = "lastname", rel = "lastname")
public List<Author> findByLastNameIgnoreCaseContaining(
@Param("lastname") String lastName
);
}

+ 1
- 1
bookstore/src/main/java/com/fjordtek/bookstore/model/BookRepository.java View File

@ -31,7 +31,7 @@ public interface BookRepository extends CrudRepository<Book, Long> {
public Optional<Book> findById(Long id);
@RestResource(path = "title", rel = "title")
public List<Book> findByTitle(@Param("name") String title);
public List<Book> findByTitleIgnoreCaseContaining(@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,


Loading…
Cancel
Save