Michelle DiMarino 5 år sedan
förälder
incheckning
060b956985

Binär
.DS_Store Visa fil


+ 14
- 2
pom.xml Visa fil

14
 	<parent>
14
 	<parent>
15
 		<groupId>org.springframework.boot</groupId>
15
 		<groupId>org.springframework.boot</groupId>
16
 		<artifactId>spring-boot-starter-parent</artifactId>
16
 		<artifactId>spring-boot-starter-parent</artifactId>
17
-		<version>2.0.4.RELEASE</version>
17
+		<version>1.5.11.RELEASE</version>
18
 		<relativePath/> <!-- lookup parent from repository -->
18
 		<relativePath/> <!-- lookup parent from repository -->
19
 	</parent>
19
 	</parent>
20
 
20
 
26
 
26
 
27
 	<dependencies>
27
 	<dependencies>
28
 		<dependency>
28
 		<dependency>
29
+			<groupId>org.hsqldb</groupId>
30
+			<artifactId>hsqldb</artifactId>
31
+			<scope>runtime</scope>
32
+		</dependency>
33
+
34
+		<dependency>
29
 			<groupId>org.springframework.boot</groupId>
35
 			<groupId>org.springframework.boot</groupId>
30
 			<artifactId>spring-boot-starter</artifactId>
36
 			<artifactId>spring-boot-starter</artifactId>
31
 		</dependency>
37
 		</dependency>
50
 			<artifactId>spring-data-commons</artifactId>
56
 			<artifactId>spring-data-commons</artifactId>
51
 			<version>1.13.10.RELEASE</version>
57
 			<version>1.13.10.RELEASE</version>
52
 		</dependency>
58
 		</dependency>
53
-	</dependencies>
59
+        <dependency>
60
+            <groupId>org.springframework.boot</groupId>
61
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
62
+            <version>RELEASE</version>
63
+            <scope>compile</scope>
64
+        </dependency>
65
+    </dependencies>
54
 
66
 
55
 	<build>
67
 	<build>
56
 		<plugins>
68
 		<plugins>

+ 5
- 0
src/main/java/com/zipcodewilmington/bakery/BakeryApplication.java Visa fil

3
 import org.springframework.boot.SpringApplication;
3
 import org.springframework.boot.SpringApplication;
4
 import org.springframework.boot.autoconfigure.SpringBootApplication;
4
 import org.springframework.boot.autoconfigure.SpringBootApplication;
5
 
5
 
6
+import javax.persistence.EntityManager;
7
+import javax.persistence.EntityManagerFactory;
8
+import javax.persistence.Persistence;
9
+
6
 @SpringBootApplication
10
 @SpringBootApplication
7
 public class BakeryApplication {
11
 public class BakeryApplication {
8
 
12
 
9
 	public static void main(String[] args) {
13
 	public static void main(String[] args) {
14
+
10
 		SpringApplication.run(BakeryApplication.class, args);
15
 		SpringApplication.run(BakeryApplication.class, args);
11
 	}
16
 	}
12
 }
17
 }

+ 21
- 1
src/main/java/com/zipcodewilmington/bakery/Controllers/BakerController.java Visa fil

2
 
2
 
3
 import com.zipcodewilmington.bakery.Models.Baker;
3
 import com.zipcodewilmington.bakery.Models.Baker;
4
 import com.zipcodewilmington.bakery.Repositories.BakerRepository;
4
 import com.zipcodewilmington.bakery.Repositories.BakerRepository;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.context.annotation.Bean;
5
 import org.springframework.http.HttpStatus;
7
 import org.springframework.http.HttpStatus;
6
 import org.springframework.http.ResponseEntity;
8
 import org.springframework.http.ResponseEntity;
7
-
9
+import org.springframework.orm.jpa.JpaVendorAdapter;
10
+import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
11
+import org.springframework.stereotype.Controller;
12
+import org.springframework.web.bind.annotation.DeleteMapping;
13
+import org.springframework.web.bind.annotation.GetMapping;
14
+import org.springframework.web.bind.annotation.PostMapping;
15
+import org.springframework.web.bind.annotation.PutMapping;
16
+
17
+import javax.activation.DataSource;
18
+import javax.persistence.EntityManagerFactory;
19
+
20
+@Controller
8
 public class BakerController {
21
 public class BakerController {
9
 
22
 
23
+    @Autowired
10
     private BakerRepository bakerRepository;
24
     private BakerRepository bakerRepository;
11
 
25
 
26
+
27
+    @GetMapping(path = "/baker")
12
     public ResponseEntity<Iterable<Baker>> index() {
28
     public ResponseEntity<Iterable<Baker>> index() {
13
         return new ResponseEntity<>(this.bakerRepository.findAll(), HttpStatus.OK);
29
         return new ResponseEntity<>(this.bakerRepository.findAll(), HttpStatus.OK);
14
     }
30
     }
15
 
31
 
32
+    @GetMapping(path = "/baker/{id}")
16
     public ResponseEntity<Baker> show(Long id) {
33
     public ResponseEntity<Baker> show(Long id) {
17
         return new ResponseEntity<>(this.bakerRepository.findOne(id), HttpStatus.OK);
34
         return new ResponseEntity<>(this.bakerRepository.findOne(id), HttpStatus.OK);
18
     }
35
     }
19
 
36
 
37
+    @PostMapping(path = "/baker")
20
     public ResponseEntity<Baker> create(Baker baker) {
38
     public ResponseEntity<Baker> create(Baker baker) {
21
         return new ResponseEntity<>(this.bakerRepository.save(baker), HttpStatus.CREATED);
39
         return new ResponseEntity<>(this.bakerRepository.save(baker), HttpStatus.CREATED);
22
     }
40
     }
23
 
41
 
42
+    @PutMapping(path = "/baker")
24
     public ResponseEntity<Baker> update(Long id, Baker baker) {
43
     public ResponseEntity<Baker> update(Long id, Baker baker) {
25
         Baker foundBaker = bakerRepository.findOne(id);
44
         Baker foundBaker = bakerRepository.findOne(id);
26
 
45
 
30
         return new ResponseEntity<>(this.bakerRepository.save(foundBaker), HttpStatus.OK);
49
         return new ResponseEntity<>(this.bakerRepository.save(foundBaker), HttpStatus.OK);
31
     }
50
     }
32
 
51
 
52
+    @DeleteMapping(path = "/baker")
33
     public ResponseEntity<Boolean> destroy(Long id) {
53
     public ResponseEntity<Boolean> destroy(Long id) {
34
         this.bakerRepository.delete(id);
54
         this.bakerRepository.delete(id);
35
         return new ResponseEntity<>(true, HttpStatus.OK);
55
         return new ResponseEntity<>(true, HttpStatus.OK);

+ 17
- 0
src/main/java/com/zipcodewilmington/bakery/Controllers/MuffinController.java Visa fil

2
 
2
 
3
 import com.zipcodewilmington.bakery.Models.Muffin;
3
 import com.zipcodewilmington.bakery.Models.Muffin;
4
 import com.zipcodewilmington.bakery.Repositories.MuffinRepository;
4
 import com.zipcodewilmington.bakery.Repositories.MuffinRepository;
5
+import org.springframework.beans.factory.annotation.Autowired;
5
 import org.springframework.http.HttpStatus;
6
 import org.springframework.http.HttpStatus;
6
 import org.springframework.http.ResponseEntity;
7
 import org.springframework.http.ResponseEntity;
8
+import org.springframework.stereotype.Controller;
9
+import org.springframework.web.bind.annotation.DeleteMapping;
10
+import org.springframework.web.bind.annotation.GetMapping;
11
+import org.springframework.web.bind.annotation.PostMapping;
12
+import org.springframework.web.bind.annotation.PutMapping;
7
 
13
 
14
+import javax.persistence.EntityManager;
15
+import javax.persistence.EntityManagerFactory;
16
+import javax.persistence.Persistence;
17
+
18
+@Controller
8
 public class MuffinController {
19
 public class MuffinController {
9
 
20
 
21
+    @Autowired
10
     private MuffinRepository muffinRepository;
22
     private MuffinRepository muffinRepository;
11
 
23
 
24
+    @GetMapping(path = "/muffin")
12
     public ResponseEntity<Iterable<Muffin>> index() {
25
     public ResponseEntity<Iterable<Muffin>> index() {
13
         return new ResponseEntity<>(this.muffinRepository.findAll(), HttpStatus.OK);
26
         return new ResponseEntity<>(this.muffinRepository.findAll(), HttpStatus.OK);
14
     }
27
     }
15
 
28
 
29
+    @GetMapping(path = "/muffin/{id}")
16
     public ResponseEntity<Muffin> show(Long id) {
30
     public ResponseEntity<Muffin> show(Long id) {
17
         return new ResponseEntity<>(this.muffinRepository.findOne(id), HttpStatus.OK);
31
         return new ResponseEntity<>(this.muffinRepository.findOne(id), HttpStatus.OK);
18
     }
32
     }
19
 
33
 
34
+    @PostMapping(path = "/muffin")
20
     public ResponseEntity<Muffin> create(Muffin muffin) {
35
     public ResponseEntity<Muffin> create(Muffin muffin) {
21
         return new ResponseEntity<>(this.muffinRepository.save(muffin), HttpStatus.CREATED);
36
         return new ResponseEntity<>(this.muffinRepository.save(muffin), HttpStatus.CREATED);
22
     }
37
     }
23
 
38
 
39
+    @PutMapping(path = "/muffin")
24
     public ResponseEntity<Muffin> update(Long id, Muffin muffin) {
40
     public ResponseEntity<Muffin> update(Long id, Muffin muffin) {
25
         Muffin foundMuffin = muffinRepository.findOne(id);
41
         Muffin foundMuffin = muffinRepository.findOne(id);
26
         foundMuffin.setFlavor(muffin.getFlavor());
42
         foundMuffin.setFlavor(muffin.getFlavor());
28
         return new ResponseEntity<>(this.muffinRepository.save(foundMuffin), HttpStatus.OK);
44
         return new ResponseEntity<>(this.muffinRepository.save(foundMuffin), HttpStatus.OK);
29
     }
45
     }
30
 
46
 
47
+    @DeleteMapping(path = "/muffin")
31
     public ResponseEntity<Boolean> destroy(Long id) {
48
     public ResponseEntity<Boolean> destroy(Long id) {
32
         this.muffinRepository.delete(id);
49
         this.muffinRepository.delete(id);
33
         return new ResponseEntity<>(true, HttpStatus.OK);
50
         return new ResponseEntity<>(true, HttpStatus.OK);

+ 11
- 0
src/main/java/com/zipcodewilmington/bakery/Models/Baker.java Visa fil

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

+ 9
- 0
src/main/java/com/zipcodewilmington/bakery/Models/Muffin.java Visa fil

1
 package com.zipcodewilmington.bakery.Models;
1
 package com.zipcodewilmington.bakery.Models;
2
 
2
 
3
+import org.springframework.data.annotation.Id;
4
+
5
+import javax.persistence.*;
6
+
7
+@Entity
3
 public class Muffin {
8
 public class Muffin {
4
 
9
 
10
+    @Id
11
+    @GeneratedValue(strategy = GenerationType.AUTO)
5
     private Long id;
12
     private Long id;
6
 
13
 
14
+    @Column
7
     private String flavor;
15
     private String flavor;
8
 
16
 
17
+
9
     public Muffin(String flavor) {
18
     public Muffin(String flavor) {
10
         this.flavor = flavor;
19
         this.flavor = flavor;
11
     }
20
     }

+ 2
- 0
src/main/java/com/zipcodewilmington/bakery/Repositories/BakerRepository.java Visa fil

2
 
2
 
3
 import com.zipcodewilmington.bakery.Models.Baker;
3
 import com.zipcodewilmington.bakery.Models.Baker;
4
 import org.springframework.data.repository.CrudRepository;
4
 import org.springframework.data.repository.CrudRepository;
5
+import org.springframework.stereotype.Repository;
5
 
6
 
7
+@Repository
6
 public interface BakerRepository extends CrudRepository<Baker, Long> {
8
 public interface BakerRepository extends CrudRepository<Baker, Long> {
7
 }
9
 }

+ 2
- 0
src/main/java/com/zipcodewilmington/bakery/Repositories/MuffinRepository.java Visa fil

2
 
2
 
3
 import com.zipcodewilmington.bakery.Models.Muffin;
3
 import com.zipcodewilmington.bakery.Models.Muffin;
4
 import org.springframework.data.repository.CrudRepository;
4
 import org.springframework.data.repository.CrudRepository;
5
+import org.springframework.stereotype.Repository;
5
 
6
 
7
+@Repository
6
 public interface MuffinRepository extends CrudRepository<Muffin, Long> {
8
 public interface MuffinRepository extends CrudRepository<Muffin, Long> {
7
 }
9
 }