From the course: Creating Spring Boot Microservices

Unlock the full course today

Join today to access over 24,500 courses taught by industry experts.

Create the RestController HTTP GET endpoint

Create the RestController HTTP GET endpoint - Spring Boot Tutorial

From the course: Creating Spring Boot Microservices

Create the RestController HTTP GET endpoint

- [Instructor] Now let's create two new APIs. One to look all the ratings for a tour and the other to calculate the average score for all the ratings. I think it's best to hide the implementation of tour ratings entity from the API. So we will return a list of tour DTO objects. We're going to do a get mapping. And we're going to return a list of rating DTOs. Let's import the list. So let's get the tour ratings from the database first. From the service. Going to look up ratings by the tour ID. And now we need to convert these tour rating entities into rating DTOs. Okay? And now we want to calculate the average by setting the URL with a slash average at the end. And we will return with a packet of key value pairs of the word average, and then the actual average score. So now we're going to have the slash average at the end of the URL. Import the map. So our key would be the word average. Then we call the tour rating service, get average score, and then pass in the tour ID. So this will…

Contents