|
@@ -6,22 +6,20 @@ import org.springframework.beans.factory.annotation.Autowired;
|
6
|
6
|
import org.springframework.http.HttpStatus;
|
7
|
7
|
import org.springframework.http.ResponseEntity;
|
8
|
8
|
|
9
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
10
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
11
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
9
|
+import org.springframework.web.bind.annotation.*;
|
12
|
10
|
|
13
|
11
|
@RestController
|
14
|
12
|
public class PersonController {
|
15
|
13
|
@Autowired
|
16
|
14
|
PersonService personService;
|
17
|
15
|
|
18
|
|
- @RequestMapping(value="/people", method= RequestMethod.GET)
|
|
16
|
+ @GetMapping(value="/people")
|
19
|
17
|
public ResponseEntity<Iterable<Person>> getPeople() {
|
20
|
18
|
Iterable<Person> people = personService.getAllPeople();
|
21
|
19
|
return new ResponseEntity<>(people, HttpStatus.OK);
|
22
|
20
|
}
|
23
|
21
|
|
24
|
|
- @RequestMapping(value = "/people/{id}", method = RequestMethod.GET)
|
|
22
|
+ @GetMapping(value = "/people/{id}")
|
25
|
23
|
public ResponseEntity<Person> getPersonById(@PathVariable Integer id) {
|
26
|
24
|
Person p = personService.findPersonById(id);
|
27
|
25
|
return new ResponseEntity<>(p, HttpStatus.OK);
|
|
@@ -32,4 +30,28 @@ public class PersonController {
|
32
|
30
|
personService.add(p);
|
33
|
31
|
return new ResponseEntity<>(p, HttpStatus.CREATED);
|
34
|
32
|
}
|
|
33
|
+
|
|
34
|
+ @DeleteMapping("/people/{id}")
|
|
35
|
+ public ResponseEntity<Person> deletePerson(@PathVariable Integer id) {
|
|
36
|
+ personService.remove(id);
|
|
37
|
+ return new ResponseEntity<>(HttpStatus.OK);
|
|
38
|
+ }
|
|
39
|
+
|
|
40
|
+ @GetMapping("/people/reverseLookup/{mobilenumber}")
|
|
41
|
+ public ResponseEntity<Iterable<Person>> lookupByMobile(@PathVariable String mobile) {
|
|
42
|
+ Iterable<Person> p = personService.findPeopleByMobile(mobile);
|
|
43
|
+ return new ResponseEntity<>(p, HttpStatus.OK);
|
|
44
|
+ }
|
|
45
|
+ @GetMapping("/people/surname/{lastname}")
|
|
46
|
+ public ResponseEntity<Iterable<Person>> getByLastName(@PathVariable String lastName) {
|
|
47
|
+ Iterable<Person> p = personService.findPeopleByLastName(lastName);
|
|
48
|
+ return new ResponseEntity<>(p, HttpStatus.OK);
|
|
49
|
+ }
|
|
50
|
+ @GetMapping("/people/surname")
|
|
51
|
+ public ResponseEntity<Iterable<Person>> getSurnames(String lastName) {
|
|
52
|
+ Iterable<Person> p = personService.generateSurnameMap(lastName);
|
|
53
|
+ return new ResponseEntity<>(p, HttpStatus.OK);
|
|
54
|
+ }
|
|
55
|
+// @GetMapping("/people/firstname/stats")
|
|
56
|
+//
|
35
|
57
|
}
|