Scenario: You are working on a RESTful API for a bookstore using Java with Spring Boot. The bookstore has books, authors, and categories. You need to implement an endpoint that allows users to search for books by title, author, or category. Task: Write a controller method that handles a GET request to search for books. The method should accept query parameters for title, author, and category, and return a list of books that match the search criteria.
Requirements (Reference: Clare, Colin)
• Use Spring Boot for the REST API implementation.
• Use Gradle as the build tool.
• Use an in-memory database (e.g., H2) for simplicity.
• Implement error handling to return appropriate error responses if no books are found or the request is invalid.
Here's a basic outline of how you could implement this:
1. Define Book, Author, and Category entities with appropriate relationships.
2. Create repositories for each entity.
3. Implement a service class with a method to search for books.
4. Create a controller class with a method to handle the search request.
- Books
- Authors
- Categories
- Java 21
- Maven
- MySQL
- PostMan
mvn clean install
mvn spring-boot:run
- http://localhost:8080/api/bookstore/book
- http://localhost:8080/api/bookstore/author
- http://localhost:8080/api/bookstore/category
- Logger slf4j integration
- Hibernate integration from current JDBC connection
- Dokerizing the app
- Deploy over the AWS or cloud from localhost
- Adding the test cases using Junit
- Developing frontend
- Developing Swagger for END point use instruction