I have two models:
// users.java
@Document(collection="user")
public class User {
@MongoId(FieldType.STRING)
private String id;
private String firstname;
// ....
}
// cars.java
@Document(collection="cars")
public class Cars {
@MongoId(FieldType.STRING)
private String id;
private String owner;
private String type;
private String year;
}
How to collect the data with Spring Rest in controllers like:
@PostMapping("add")
public String save (@RequestBody User user,@RequestBody Cars cars){
String theUser = user.getFirstname;
String theCars = cars.getType;
}
I need to save JSON like below:
{
"firstname": "Smith",
"type": "kfc",
// more data blabla ......
}
Please tell me if you need more data like my pom.xml or other.