Parcourir la source

annotatedworking

Seth il y a 5 ans
Parent
révision
10c17931e1

+ 6
- 1
pom.xml Voir le fichier

@@ -14,7 +14,7 @@
14 14
 	<parent>
15 15
 		<groupId>org.springframework.boot</groupId>
16 16
 		<artifactId>spring-boot-starter-parent</artifactId>
17
-		<version>2.0.4.RELEASE</version>
17
+		<version>1.5.11.RELEASE</version>
18 18
 		<relativePath/> <!-- lookup parent from repository -->
19 19
 	</parent>
20 20
 
@@ -54,6 +54,11 @@
54 54
             <groupId>org.springframework.boot</groupId>
55 55
             <artifactId>spring-boot-starter-data-jpa</artifactId>
56 56
         </dependency>
57
+		<dependency>
58
+			<groupId>org.hsqldb</groupId>
59
+			<artifactId>hsqldb</artifactId>
60
+			<scope>runtime</scope>
61
+		</dependency>
57 62
     </dependencies>
58 63
 
59 64
 	<build>

+ 4
- 3
src/main/java/com/zipcodewilmington/bakery/Controllers/BakerController.java Voir le fichier

@@ -3,6 +3,7 @@ package com.zipcodewilmington.bakery.Controllers;
3 3
 import com.zipcodewilmington.bakery.Models.Baker;
4 4
 import com.zipcodewilmington.bakery.Repositories.BakerRepository;
5 5
 import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.data.rest.core.annotation.RepositoryEventHandler;
6 7
 import org.springframework.http.HttpStatus;
7 8
 import org.springframework.http.ResponseEntity;
8 9
 import org.springframework.web.bind.annotation.*;
@@ -18,8 +19,8 @@ public class BakerController {
18 19
         return new ResponseEntity<>(this.bakerRepository.findAll(), HttpStatus.OK);
19 20
     }
20 21
 
21
-    @GetMapping("/bakers")
22
-    public ResponseEntity<Baker> show(Long id) {
22
+    @GetMapping("/bakers/{id}")
23
+    public ResponseEntity<Baker> show(@PathVariable Long id) {
23 24
         return new ResponseEntity<>(this.bakerRepository.findOne(id), HttpStatus.OK);
24 25
     }
25 26
 
@@ -38,7 +39,7 @@ public class BakerController {
38 39
         return new ResponseEntity<>(this.bakerRepository.save(foundBaker), HttpStatus.OK);
39 40
     }
40 41
 
41
-    @DeleteMapping("/bakers")
42
+    @DeleteMapping("/bakers/")
42 43
     public ResponseEntity<Boolean> destroy(Long id) {
43 44
         this.bakerRepository.delete(id);
44 45
         return new ResponseEntity<>(true, HttpStatus.OK);

+ 2
- 2
src/main/java/com/zipcodewilmington/bakery/Controllers/MuffinController.java Voir le fichier

@@ -19,8 +19,8 @@ public class MuffinController {
19 19
         return new ResponseEntity<>(this.muffinRepository.findAll(), HttpStatus.OK);
20 20
     }
21 21
 
22
-    @GetMapping("/muffins")
23
-    public ResponseEntity<Muffin> show(Long id) {
22
+    @GetMapping("/muffins/{id}")
23
+    public ResponseEntity<Muffin> show(@PathVariable Long id) {
24 24
         return new ResponseEntity<>(this.muffinRepository.findOne(id), HttpStatus.OK);
25 25
     }
26 26
 

+ 2
- 0
src/main/java/com/zipcodewilmington/bakery/Models/Baker.java Voir le fichier

@@ -1,11 +1,13 @@
1 1
 package com.zipcodewilmington.bakery.Models;
2 2
 
3 3
 import javax.persistence.Entity;
4
+import javax.persistence.GeneratedValue;
4 5
 import javax.persistence.Id;
5 6
 
6 7
 @Entity
7 8
 public class Baker {
8 9
     @Id
10
+    @GeneratedValue
9 11
     private Long id;
10 12
 
11 13
     private String name;