Browse Source

started service layer

mpierse 5 years ago
parent
commit
2f403e8662

+ 51
- 1
src/main/java/io/zipcoder/persistenceapp/Person.java View File

@@ -1,5 +1,55 @@
1 1
 package io.zipcoder.persistenceapp;
2 2
 
3
+import java.util.Date;
4
+
3 5
 public class Person {
4
-    
6
+
7
+    private Long id;
8
+    private String firstName;
9
+    private String lastName;
10
+    private Date birthDate;
11
+
12
+    public Person(){
13
+        firstName="Juliette";
14
+        lastName="Lowe";
15
+        birthDate=new Date(1900, 12,3);
16
+    }
17
+
18
+    public Person(String firstName, String lastName, Date birthDate) {
19
+        this.firstName = firstName;
20
+        this.lastName = lastName;
21
+        this.birthDate = birthDate;
22
+    }
23
+
24
+    public Long getId() {
25
+        return id;
26
+    }
27
+
28
+    public void setId(Long id) {
29
+        this.id = id;
30
+    }
31
+
32
+    public String getFirstName() {
33
+        return firstName;
34
+    }
35
+
36
+    public void setFirstName(String firstName) {
37
+        this.firstName = firstName;
38
+    }
39
+
40
+    public String getLastName() {
41
+        return lastName;
42
+    }
43
+
44
+    public void setLastName(String lastName) {
45
+        this.lastName = lastName;
46
+    }
47
+
48
+    public Date getBirthDate() {
49
+        return birthDate;
50
+    }
51
+
52
+    public void setBirthDate(Date birthDate) {
53
+        this.birthDate = birthDate;
54
+    }
5 55
 }

+ 12
- 0
src/main/java/io/zipcoder/persistenceapp/PersonController.java View File

@@ -0,0 +1,12 @@
1
+package io.zipcoder.persistenceapp;
2
+
3
+import org.springframework.web.bind.annotation.RequestMapping;
4
+import org.springframework.web.bind.annotation.RequestMethod;
5
+import org.springframework.web.bind.annotation.RestController;
6
+
7
+@RestController
8
+public class PersonController {
9
+
10
+    @RequestMapping(value = "/people", method = RequestMethod.POST)
11
+    public Person createPerson
12
+}

+ 6
- 0
src/main/java/io/zipcoder/persistenceapp/PersonRepository.java View File

@@ -0,0 +1,6 @@
1
+package io.zipcoder.persistenceapp;
2
+
3
+import org.springframework.data.jpa.repository.JpaRepository;
4
+
5
+public interface PersonRepository extends JpaRepository {
6
+}

+ 3
- 0
src/main/java/io/zipcoder/persistenceapp/PersonService.java View File

@@ -5,5 +5,8 @@ import org.springframework.stereotype.Service;
5 5
 @Service
6 6
 public class PersonService {
7 7
 
8
+public Person createPerson(){
9
+    return new Person();
10
+}
8 11
 
9 12
 }

+ 1
- 1
src/main/resources/application-h2.properties View File

@@ -1,4 +1,4 @@
1
-spring.datasource.url=jdbc:h2:mem:testdb;Mode=Oracle
1
+spring.datasource.url=jdbc:h2:mem:test;Mode=Oracle
2 2
 spring.datasource.platform=h2
3 3
 spring.jpa.hibernate.ddl-auto=none
4 4
 spring.datasource.continue-on-error=true