Seth vor 6 Jahren
Ursprung
Commit
e919e263c5

+ 1
- 1
pom.xml Datei anzeigen

@@ -14,7 +14,7 @@
14 14
 	<parent>
15 15
 		<groupId>org.springframework.boot</groupId>
16 16
 		<artifactId>spring-boot-starter-parent</artifactId>
17
-		<version>1.5.2.RELEASE</version>
17
+		<version>2.1.1.RELEASE</version>
18 18
 		<relativePath/> <!-- lookup parent from repository -->
19 19
 	</parent>
20 20
 

+ 35
- 0
src/main/java/io/zipcoder/crudapp/Person.java Datei anzeigen

@@ -0,0 +1,35 @@
1
+package io.zipcoder.crudapp;
2
+
3
+public class Person {
4
+    private String firstName;
5
+    private String lastName;
6
+    private int id;
7
+
8
+    public Person() {
9
+
10
+    }
11
+
12
+    public String getFirstName() {
13
+        return firstName;
14
+    }
15
+
16
+    public void setFirstName(String firstName) {
17
+        this.firstName = firstName;
18
+    }
19
+
20
+    public String getLastName() {
21
+        return lastName;
22
+    }
23
+
24
+    public void setLastName(String lastName) {
25
+        this.lastName = lastName;
26
+    }
27
+
28
+    public int getId() {
29
+        return id;
30
+    }
31
+
32
+    public void setId(int id) {
33
+        this.id = id;
34
+    }
35
+}

+ 45
- 0
src/main/java/io/zipcoder/crudapp/PersonController.java Datei anzeigen

@@ -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
+}