Learn how to intercept HTTP POST commands with RestController methods.
- [Mary Ellen Bowman] Now, let's implement an API…to create a TourRating.…But can all the attributes of a TourRating…be sent in the request body?…Well, let's look at TourRating.…So we have an attribute score that can easily be sent.…It's just an Integer. Comment is a String; that's fine.…TourRatingPK, let's look inside that:…we have a Tour and a customerID.…Well, a customerID is fine, but the client…would likely send the Tour identifier, not the entire Tour,…so we should create a Data Transfer Object…to encapsulate the request body.…
So in this web folder, I have in the exercise file…a RatingDto and so the attributes on the RatingDto…are the score, a comment, and a customerID.…We don't have the tourId in here because that's going to be…a parameter on the URL.…So we can apply java validations on here:…the minimum score is 0, the maximum score is 5,…the maximum number of characters…in the comment String is 255,…and the customerID is NotNull.…
So whenever this RatingDto is passed in to…the Create method as a request body,…
- 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.