CRUD Library
- Model: layer where the classes that represent the tables in the database are created
- Controller: is the presentation layer where the end points are located
- Service: is the service layer where the business logic resides
- Repository: is the persistence layer where the CRUD repository is located
- Exception:
- Configuration:
- Spring Boot (spring-boot-starter-web, spring-boot-starter-data-jpa, spring-boot-starter-test, spring-boot-starter-validation)
- Java 11
- Gradle
- JPA
- MySQL
- JUnit and Mockito
- Integration Test (for the Controller): it uses the Spring Boot Test framework with mockMvc and Jupyter
- Unit Test
- for the Service: it uses the Mockito framework with hamcrest matchers, mock and injectMocks annotations
- for the Repository:
http://localhost:8081/api/book
HTTP Method: GET
Get all books
http://localhost:8081/api/book/getAllBooks
Get book by Id
http://localhost:8081/api/book/getBookById/{bookId}
Get books by State
http://localhost:8081/api/book/getBookByState/{state}
HTTP Method: POST
Create book
http://localhost:8080/api/book/createBook
{
"title": "Title A",
"author": "Anonymous",
"editorialYear": 2000,
"state": "AVAILABLE",
"reservation": null
}
HTTP Method: PUT
Update book by Id
http://localhost:8080/api/book/updateBook/{bookId}
{
"title": "Title B",
"author": "Somebody",
"editorialYear": 2021,
"state": "AVAILABLE",
"reservation": null
}
Update reservation by book Id
http://localhost:8080/api/book/updateReservationByBookId/{bookId}
{
"startDate": "10-05-2021",
"endDate": "26-06-2021"
}
HTTP Method: DELETE
Delete book by Id
http://localhost:8081/api/book/deleteBookById/{bookId}