|
@@ -1,6 +1,7 @@
|
1
|
1
|
package io.zipcoder.persistenceapp.controller;
|
2
|
2
|
|
3
|
3
|
import io.zipcoder.persistenceapp.model.Home;
|
|
4
|
+import io.zipcoder.persistenceapp.model.Person;
|
4
|
5
|
import io.zipcoder.persistenceapp.service.HomeService;
|
5
|
6
|
import org.springframework.beans.factory.annotation.Autowired;
|
6
|
7
|
import org.springframework.http.HttpStatus;
|
|
@@ -49,10 +50,16 @@ public class HomeController {
|
49
|
50
|
return new ResponseEntity<>(h, HttpStatus.OK);
|
50
|
51
|
}
|
51
|
52
|
|
52
|
|
- @GetMapping(value = "/homes/people/{id}")
|
|
53
|
+ @GetMapping(value = "/homes/people/{personId}")
|
53
|
54
|
public ResponseEntity<Home> getHomeForPersonId(@PathVariable Integer personId) {
|
54
|
55
|
Home h = homeService.findHomeByPersonId(personId);
|
55
|
56
|
return new ResponseEntity<>(h, HttpStatus.OK);
|
56
|
57
|
}
|
57
|
58
|
|
|
59
|
+ @GetMapping(value = "/homes/{homeId}/people")
|
|
60
|
+ public ResponseEntity<Iterable<Person>> getPeopleInHome(@PathVariable Integer homeId){
|
|
61
|
+ Iterable<Person> people = homeService.generatePeopleInHome(homeId);
|
|
62
|
+ return new ResponseEntity<>(people, HttpStatus.OK);
|
|
63
|
+ }
|
|
64
|
+
|
58
|
65
|
}
|