Learn how to intercept HTTP GET commands with RestController methods.
- [Instructor] Now let's create two new APIs,…one to look up all the ratings for tour,…and another to calculate the average score…of all the ratings.…I think it is best to hide the implementation…of tour ratings entity from the API,…so we will return a list of tour DTO objects,…and we will calculate the average…by setting the URL with the slash average at the end,…and then we'll return adjacent packet…with the key value pair of average…and then the actual average score.…
So we are now in our tour rating controller,…and I have a helper method in here…that will convert a tour rating to a rating DTO.…First let's do our get,…get all ratings for a tour.…Again, we have our path variable for the tour ID.…
Now let's annotate this properly.…We want the request mapping to do just get…on the base URL.…So the first step is we're going to verify…the tour using the tour ID that's passed in,…and now we're going to look up all the ratings…for a tour and stream them to a map,…and then for each element in the stream,…we're going to convert the tour rating…
- Setting up the project
- Building, deploying, and launch the microservice
- Declaring Spring Data JPA repository interfaces
- Invoking repositories
- Using Spring Data query methods
- Exposing RESTful APIs with Spring Data REST
- Using the /search resource to invoke query methods
- Paging and sorting
- Declaring a new REST controller
- Creating HTTP methods for creating, reading, updating and deleting persistent data.