ソースを参照

bakery finished

Kate Moore 5 年 前
コミット
e13c11b6fa

バイナリ
.DS_Store ファイルの表示


+ 62
- 51
pom.xml ファイルの表示

@@ -1,65 +1,76 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
-	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4
-	<modelVersion>4.0.0</modelVersion>
3
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4
+    <modelVersion>4.0.0</modelVersion>
5 5
 
6
-	<groupId>com.zipcodewilmington</groupId>
7
-	<artifactId>bakery</artifactId>
8
-	<version>0.0.1-SNAPSHOT</version>
9
-	<packaging>jar</packaging>
6
+    <groupId>com.zipcodewilmington</groupId>
7
+    <artifactId>bakery</artifactId>
8
+    <version>0.0.1-SNAPSHOT</version>
9
+    <packaging>jar</packaging>
10 10
 
11
-	<name>bakery</name>
12
-	<description>Demo project for Spring Boot</description>
11
+    <name>bakery</name>
12
+    <description>Demo project for Spring Boot</description>
13 13
 
14
-	<parent>
15
-		<groupId>org.springframework.boot</groupId>
16
-		<artifactId>spring-boot-starter-parent</artifactId>
17
-		<version>2.0.4.RELEASE</version>
18
-		<relativePath/> <!-- lookup parent from repository -->
19
-	</parent>
14
+    <parent>
15
+        <groupId>org.springframework.boot</groupId>
16
+        <artifactId>spring-boot-starter-parent</artifactId>
17
+        <version>2.0.4.RELEASE</version>
18
+        <relativePath/> <!-- lookup parent from repository -->
19
+    </parent>
20 20
 
21
-	<properties>
22
-		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
23
-		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
24
-		<java.version>1.8</java.version>
25
-	</properties>
21
+    <properties>
22
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
23
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
24
+        <java.version>1.8</java.version>
25
+    </properties>
26 26
 
27
-	<dependencies>
28
-		<dependency>
29
-			<groupId>org.springframework.boot</groupId>
30
-			<artifactId>spring-boot-starter</artifactId>
31
-		</dependency>
27
+    <dependencies>
28
+        <dependency>
29
+            <groupId>org.springframework.boot</groupId>
30
+            <artifactId>spring-boot-starter</artifactId>
31
+        </dependency>
32 32
 
33
-		<dependency>
34
-			<groupId>org.springframework.boot</groupId>
35
-			<artifactId>spring-boot-starter-data-rest</artifactId>
36
-		</dependency>
33
+        <dependency>
34
+            <groupId>org.springframework.boot</groupId>
35
+            <artifactId>spring-boot-starter-data-rest</artifactId>
36
+        </dependency>
37 37
 
38
-		<dependency>
39
-			<groupId>org.springframework.boot</groupId>
40
-			<artifactId>spring-boot-starter-web</artifactId>
41
-		</dependency>
38
+        <dependency>
39
+            <groupId>org.springframework.boot</groupId>
40
+            <artifactId>spring-boot-starter-web</artifactId>
41
+        </dependency>
42 42
 
43
-		<dependency>
44
-			<groupId>org.springframework.boot</groupId>
45
-			<artifactId>spring-boot-starter-test</artifactId>
46
-			<scope>test</scope>
47
-		</dependency>
48
-		<dependency>
49
-			<groupId>org.springframework.data</groupId>
50
-			<artifactId>spring-data-commons</artifactId>
51
-			<version>1.13.10.RELEASE</version>
52
-		</dependency>
53
-	</dependencies>
43
+        <dependency>
44
+            <groupId>org.springframework.boot</groupId>
45
+            <artifactId>spring-boot-starter-test</artifactId>
46
+            <scope>test</scope>
47
+        </dependency>
48
+        <dependency>
49
+            <groupId>org.springframework.data</groupId>
50
+            <artifactId>spring-data-commons</artifactId>
51
+            <version>1.13.10.RELEASE</version>
52
+        </dependency>
53
+        <dependency>
54
+            <groupId>org.springframework.boot</groupId>
55
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
56
+            <version>2.0.4.RELEASE</version>
57
+            <scope>compile</scope>
58
+        </dependency>
59
+        <dependency>
60
+            <groupId>org.hsqldb</groupId>
61
+            <artifactId>hsqldb</artifactId>
62
+            <scope>runtime</scope>
63
+        </dependency>
64
+    </dependencies>
54 65
 
55
-	<build>
56
-		<plugins>
57
-			<plugin>
58
-				<groupId>org.springframework.boot</groupId>
59
-				<artifactId>spring-boot-maven-plugin</artifactId>
60
-			</plugin>
61
-		</plugins>
62
-	</build>
66
+    <build>
67
+        <plugins>
68
+            <plugin>
69
+                <groupId>org.springframework.boot</groupId>
70
+                <artifactId>spring-boot-maven-plugin</artifactId>
71
+            </plugin>
72
+        </plugins>
73
+    </build>
63 74
 
64 75
 
65 76
 </project>

+ 10
- 0
src/main/java/com/zipcodewilmington/bakery/Controllers/BakerController.java ファイルの表示

@@ -2,25 +2,34 @@ package com.zipcodewilmington.bakery.Controllers;
2 2
 
3 3
 import com.zipcodewilmington.bakery.Models.Baker;
4 4
 import com.zipcodewilmington.bakery.Repositories.BakerRepository;
5
+import org.springframework.beans.factory.annotation.Autowired;
5 6
 import org.springframework.http.HttpStatus;
6 7
 import org.springframework.http.ResponseEntity;
8
+import org.springframework.web.bind.annotation.RequestMapping;
9
+import org.springframework.web.bind.annotation.RequestMethod;
10
+import org.springframework.web.bind.annotation.RestController;
7 11
 
12
+@RestController
8 13
 public class BakerController {
9 14
 
10 15
     private BakerRepository bakerRepository;
11 16
 
17
+    @Autowired
12 18
     public ResponseEntity<Iterable<Baker>> index() {
13 19
         return new ResponseEntity<>(this.bakerRepository.findAll(), HttpStatus.OK);
14 20
     }
15 21
 
22
+    @RequestMapping(value = "/baker", method = RequestMethod.GET)
16 23
     public ResponseEntity<Baker> show(Long id) {
17 24
         return new ResponseEntity<>(this.bakerRepository.findOne(id), HttpStatus.OK);
18 25
     }
19 26
 
27
+    @RequestMapping(value = "/baker", method = RequestMethod.POST)
20 28
     public ResponseEntity<Baker> create(Baker baker) {
21 29
         return new ResponseEntity<>(this.bakerRepository.save(baker), HttpStatus.CREATED);
22 30
     }
23 31
 
32
+    @RequestMapping(value = "/baker/{bakerid}", method = RequestMethod.PUT)
24 33
     public ResponseEntity<Baker> update(Long id, Baker baker) {
25 34
         Baker foundBaker = bakerRepository.findOne(id);
26 35
 
@@ -30,6 +39,7 @@ public class BakerController {
30 39
         return new ResponseEntity<>(this.bakerRepository.save(foundBaker), HttpStatus.OK);
31 40
     }
32 41
 
42
+    @RequestMapping(value = "/bakers/{bakerid}", method = RequestMethod.DELETE)
33 43
     public ResponseEntity<Boolean> destroy(Long id) {
34 44
         this.bakerRepository.delete(id);
35 45
         return new ResponseEntity<>(true, HttpStatus.OK);

+ 10
- 1
src/main/java/com/zipcodewilmington/bakery/Controllers/MuffinController.java ファイルの表示

@@ -2,25 +2,33 @@ package com.zipcodewilmington.bakery.Controllers;
2 2
 
3 3
 import com.zipcodewilmington.bakery.Models.Muffin;
4 4
 import com.zipcodewilmington.bakery.Repositories.MuffinRepository;
5
+import org.springframework.beans.factory.annotation.Autowired;
5 6
 import org.springframework.http.HttpStatus;
6 7
 import org.springframework.http.ResponseEntity;
8
+import org.springframework.web.bind.annotation.RequestMapping;
9
+import org.springframework.web.bind.annotation.RequestMethod;
10
+import org.springframework.web.bind.annotation.RestController;
7 11
 
12
+@RestController
8 13
 public class MuffinController {
9 14
 
10 15
     private MuffinRepository muffinRepository;
11 16
 
17
+    @Autowired
12 18
     public ResponseEntity<Iterable<Muffin>> index() {
13 19
         return new ResponseEntity<>(this.muffinRepository.findAll(), HttpStatus.OK);
14 20
     }
15
-
21
+    @RequestMapping(value="/muffin", method= RequestMethod.GET)
16 22
     public ResponseEntity<Muffin> show(Long id) {
17 23
         return new ResponseEntity<>(this.muffinRepository.findOne(id), HttpStatus.OK);
18 24
     }
19 25
 
26
+    @RequestMapping(value = "/muffin", method = RequestMethod.POST)
20 27
     public ResponseEntity<Muffin> create(Muffin muffin) {
21 28
         return new ResponseEntity<>(this.muffinRepository.save(muffin), HttpStatus.CREATED);
22 29
     }
23 30
 
31
+    @RequestMapping(value = "/muffin/{muffinid}", method = RequestMethod.POST)
24 32
     public ResponseEntity<Muffin> update(Long id, Muffin muffin) {
25 33
         Muffin foundMuffin = muffinRepository.findOne(id);
26 34
         foundMuffin.setFlavor(muffin.getFlavor());
@@ -28,6 +36,7 @@ public class MuffinController {
28 36
         return new ResponseEntity<>(this.muffinRepository.save(foundMuffin), HttpStatus.OK);
29 37
     }
30 38
 
39
+    @RequestMapping(value = "/muffin/{muffinid}", method = RequestMethod.DELETE)
31 40
     public ResponseEntity<Boolean> destroy(Long id) {
32 41
         this.muffinRepository.delete(id);
33 42
         return new ResponseEntity<>(true, HttpStatus.OK);

+ 11
- 0
src/main/java/com/zipcodewilmington/bakery/Models/Baker.java ファイルの表示

@@ -1,12 +1,23 @@
1 1
 package com.zipcodewilmington.bakery.Models;
2 2
 
3
+
4
+import javax.persistence.*;
5
+
6
+@Entity
3 7
 public class Baker {
8
+
9
+    @Id
10
+    @GeneratedValue
11
+    @Column(name = "BAKER_ID")
4 12
     private Long id;
5 13
 
14
+    @Column(name = "BAKER_NAME")
6 15
     private String name;
7 16
 
17
+    @Column(name = "BAKER_NAME")
8 18
     private String employeeId;
9 19
 
20
+    @Column(name = "BAKER_SPECIALTY")
10 21
     private String specialty;
11 22
 
12 23
     public Baker(String name, String employeeId, String specialty) {

+ 10
- 0
src/main/java/com/zipcodewilmington/bakery/Models/Muffin.java ファイルの表示

@@ -1,9 +1,19 @@
1 1
 package com.zipcodewilmington.bakery.Models;
2 2
 
3
+import javax.persistence.Column;
4
+import javax.persistence.Entity;
5
+import javax.persistence.GeneratedValue;
6
+import javax.persistence.Id;
7
+
8
+@Entity
3 9
 public class Muffin {
4 10
 
11
+    @Id
12
+    @GeneratedValue
13
+    @Column(name = "MUFFIN_ID")
5 14
     private Long id;
6 15
 
16
+    @Column(name = "MUFFIN_FLAVOR")
7 17
     private String flavor;
8 18
 
9 19
     public Muffin(String flavor) {