I'm building a rest API using Spring Boot rest services. I have a Java class:
class Person{
int id;
@notNull
String name;
@notNull
String password;
}
And I want to make an API to create a Person object. I will recieve a POST request with json body like:
{
"name":"Ahmad",
"password":"myPass",
"shouldSendEmail":1
}
As you can see there are an extra field "shouldSendEmail" that I have to use it to know if should I send an email or not after I create the Person Object. I am using the following API:
@RequestMapping(value = "/AddPerson", method = RequestMethod.POST)
public String savePerson(
@Valid @RequestBody Person person) {
personRepository.insert(person);
// Here I want to know if I should send an email or Not
return "success";
}
Is there a method to access the value of "shouldSendEmail" while I using the autoMapping in this way?