/*
consume JSON structure:
{
"mother": {
"name":"Susanne"
},
"kid": {
"name":"Peter"
}
}
constructors and accessors are omitted
*/
public class MotherWithKidDTO {
private Mother mother;
private Kid kid;
}
private class Mother {
private String name;
private Kid kid;
}
private class Kid {
private String name;
// private Mother mother; // if needed
}
@RestController
public class MotherController {
@PostMapping
public Mother createMotherWithKid(@RequestBody MotherWithKidDTO motherWithKid) {
Mother mother = motherWithKid.getMother();
Kid kid = motherWithKid.getKid();
mother.setKid(kid);
Mother created = motherService.save(mother);
return created;
}
}
Comments
0 B
|👍
/👎