Преглед изворни кода

Merge branch 'master' of https://git.zipcode.rocks/Cohort4.2/CR-MicroLabs-Annotations-Bakery

William Brown пре 5 година
родитељ
комит
ef7b57591b

+ 56
- 56
pom.xml Прегледај датотеку

@@ -1,76 +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>1.5.11.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 43
         <dependency>
54
-            <groupId>org.hsqldb</groupId>
55
-            <artifactId>hsqldb</artifactId>
56
-            <scope>runtime</scope>
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
+        </dependency>
52
+        <dependency>
53
+            <groupId>org.springframework.boot</groupId>
54
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
55
+        </dependency>
56
+        <dependency>
57
+            <groupId>com.h2database</groupId>
58
+            <artifactId>h2</artifactId>
57 59
         </dependency>
58 60
         <dependency>
59 61
             <groupId>org.springframework.boot</groupId>
60 62
             <artifactId>spring-boot-starter-data-jpa</artifactId>
61
-            <version>RELEASE</version>
62
-            <scope>compile</scope>
63 63
         </dependency>
64 64
     </dependencies>
65 65
 
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>
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>
74 74
 
75 75
 
76
-</project>
76
+</project>

+ 4
- 5
src/main/java/com/zipcodewilmington/bakery/Controllers/BakerController.java Прегледај датотеку

@@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
13 13
 @RestController
14 14
 public class BakerController {
15 15
 
16
-    private final BakerRepository bakerRepository;
16
+    private BakerRepository bakerRepository;
17 17
 
18 18
     @Autowired
19 19
     public BakerController(BakerRepository bakerRepository) {
@@ -27,7 +27,7 @@ public class BakerController {
27 27
 
28 28
     @RequestMapping(value = "/bakers/{id}", method = RequestMethod.GET)
29 29
     public ResponseEntity<Baker> show(@PathVariable Long id) {
30
-        return new ResponseEntity<>(this.bakerRepository.findOne(id), HttpStatus.OK);
30
+        return new ResponseEntity<>(this.bakerRepository.findById(id).get(), HttpStatus.OK);
31 31
     }
32 32
 
33 33
     @RequestMapping(value = "/bakers", method = RequestMethod.POST)
@@ -37,8 +37,7 @@ public class BakerController {
37 37
 
38 38
     @RequestMapping(value = "/bakers/{id}", method = RequestMethod.PUT)
39 39
     public ResponseEntity<Baker> update(@PathVariable Long id, Baker baker) {
40
-        Baker foundBaker = bakerRepository.findOne(id);
41
-
40
+        Baker foundBaker = bakerRepository.findById(id).get();
42 41
         foundBaker.setName(baker.getName());
43 42
         foundBaker.setSpecialty(baker.getSpecialty());
44 43
 
@@ -47,7 +46,7 @@ public class BakerController {
47 46
 
48 47
     @RequestMapping(value = "/bakers/{id}", method = RequestMethod.DELETE)
49 48
     public ResponseEntity<Boolean> destroy(@PathVariable Long id) {
50
-        this.bakerRepository.delete(id);
49
+        this.bakerRepository.findById(id).get();
51 50
         return new ResponseEntity<>(true, HttpStatus.OK);
52 51
     }
53 52
 }

+ 4
- 4
src/main/java/com/zipcodewilmington/bakery/Controllers/MuffinController.java Прегледај датотеку

@@ -27,8 +27,8 @@ public class MuffinController {
27 27
     }
28 28
 
29 29
     @RequestMapping(value = "/muffins/{id}", method = RequestMethod.GET)
30
-    public ResponseEntity<Muffin> show(@PathVariable Long id) {
31
-        return new ResponseEntity<>(this.muffinRepository.findOne(id), HttpStatus.OK);
30
+    public ResponseEntity<Muffin> show(Long id) {
31
+        return new ResponseEntity<>(this.muffinRepository.findById(id).get(), HttpStatus.OK);
32 32
     }
33 33
 
34 34
     @RequestMapping(value = "/muffins", method = RequestMethod.POST)
@@ -38,7 +38,7 @@ public class MuffinController {
38 38
 
39 39
     @RequestMapping(value = "/muffins/{id}", method = RequestMethod.PUT)
40 40
     public ResponseEntity<Muffin> update(@PathVariable Long id, Muffin muffin) {
41
-        Muffin foundMuffin = muffinRepository.findOne(id);
41
+        Muffin foundMuffin = muffinRepository.findById(id).get();
42 42
         foundMuffin.setFlavor(muffin.getFlavor());
43 43
 
44 44
         return new ResponseEntity<>(this.muffinRepository.save(foundMuffin), HttpStatus.OK);
@@ -46,7 +46,7 @@ public class MuffinController {
46 46
 
47 47
     @RequestMapping(value = "/muffins/{id}", method = RequestMethod.DELETE)
48 48
     public ResponseEntity<Boolean> destroy(@PathVariable Long id) {
49
-        this.muffinRepository.delete(id);
49
+        this.muffinRepository.deleteById(id);
50 50
         return new ResponseEntity<>(true, HttpStatus.OK);
51 51
     }
52 52