|
@@ -0,0 +1,45 @@
|
|
1
|
+package io.zipcoder.crudapp;
|
|
2
|
+
|
|
3
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
4
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
5
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
6
|
+import org.springframework.web.bind.annotation.RestController;
|
|
7
|
+
|
|
8
|
+import java.util.ArrayList;
|
|
9
|
+import java.util.List;
|
|
10
|
+
|
|
11
|
+import static org.springframework.web.bind.annotation.RequestMethod.GET;
|
|
12
|
+import static org.springframework.web.bind.annotation.RequestMethod.POST;
|
|
13
|
+
|
|
14
|
+@RestController
|
|
15
|
+public class PersonController {
|
|
16
|
+ private List<Person> personList = new ArrayList<>();
|
|
17
|
+
|
|
18
|
+ public PersonController(){
|
|
19
|
+
|
|
20
|
+ }
|
|
21
|
+
|
|
22
|
+ @RequestMapping(value = "/people", method = POST)
|
|
23
|
+ @RequestBody
|
|
24
|
+ public Person createPerson(Person p){
|
|
25
|
+ return new Person();
|
|
26
|
+ }
|
|
27
|
+
|
|
28
|
+ @RequestMapping(value = "/people/{id}", method = GET)
|
|
29
|
+ public Person getPerson(@PathVariable int id){
|
|
30
|
+ for(Person person: personList){
|
|
31
|
+ if(person.getId() == id){
|
|
32
|
+ return person;
|
|
33
|
+ }
|
|
34
|
+ }
|
|
35
|
+ return null;
|
|
36
|
+ }
|
|
37
|
+
|
|
38
|
+ public List<Person> getPersonList(){
|
|
39
|
+ return this.personList;
|
|
40
|
+ }
|
|
41
|
+
|
|
42
|
+ public Person updatePerson(Person p){
|
|
43
|
+ return new Person();
|
|
44
|
+ }
|
|
45
|
+}
|