Browse Source

bakery finished

Kate Moore 5 years ago
parent
commit
e13c11b6fa

BIN
.DS_Store View File


+ 62
- 51
pom.xml View File

1
 <?xml version="1.0" encoding="UTF-8"?>
1
 <?xml version="1.0" encoding="UTF-8"?>
2
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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
 </project>
76
 </project>

+ 10
- 0
src/main/java/com/zipcodewilmington/bakery/Controllers/BakerController.java View File

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;
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.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
 public class BakerController {
13
 public class BakerController {
9
 
14
 
10
     private BakerRepository bakerRepository;
15
     private BakerRepository bakerRepository;
11
 
16
 
17
+    @Autowired
12
     public ResponseEntity<Iterable<Baker>> index() {
18
     public ResponseEntity<Iterable<Baker>> index() {
13
         return new ResponseEntity<>(this.bakerRepository.findAll(), HttpStatus.OK);
19
         return new ResponseEntity<>(this.bakerRepository.findAll(), HttpStatus.OK);
14
     }
20
     }
15
 
21
 
22
+    @RequestMapping(value = "/baker", method = RequestMethod.GET)
16
     public ResponseEntity<Baker> show(Long id) {
23
     public ResponseEntity<Baker> show(Long id) {
17
         return new ResponseEntity<>(this.bakerRepository.findOne(id), HttpStatus.OK);
24
         return new ResponseEntity<>(this.bakerRepository.findOne(id), HttpStatus.OK);
18
     }
25
     }
19
 
26
 
27
+    @RequestMapping(value = "/baker", method = RequestMethod.POST)
20
     public ResponseEntity<Baker> create(Baker baker) {
28
     public ResponseEntity<Baker> create(Baker baker) {
21
         return new ResponseEntity<>(this.bakerRepository.save(baker), HttpStatus.CREATED);
29
         return new ResponseEntity<>(this.bakerRepository.save(baker), HttpStatus.CREATED);
22
     }
30
     }
23
 
31
 
32
+    @RequestMapping(value = "/baker/{bakerid}", method = RequestMethod.PUT)
24
     public ResponseEntity<Baker> update(Long id, Baker baker) {
33
     public ResponseEntity<Baker> update(Long id, Baker baker) {
25
         Baker foundBaker = bakerRepository.findOne(id);
34
         Baker foundBaker = bakerRepository.findOne(id);
26
 
35
 
30
         return new ResponseEntity<>(this.bakerRepository.save(foundBaker), HttpStatus.OK);
39
         return new ResponseEntity<>(this.bakerRepository.save(foundBaker), HttpStatus.OK);
31
     }
40
     }
32
 
41
 
42
+    @RequestMapping(value = "/bakers/{bakerid}", method = RequestMethod.DELETE)
33
     public ResponseEntity<Boolean> destroy(Long id) {
43
     public ResponseEntity<Boolean> destroy(Long id) {
34
         this.bakerRepository.delete(id);
44
         this.bakerRepository.delete(id);
35
         return new ResponseEntity<>(true, HttpStatus.OK);
45
         return new ResponseEntity<>(true, HttpStatus.OK);

+ 10
- 1
src/main/java/com/zipcodewilmington/bakery/Controllers/MuffinController.java View File

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.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
 public class MuffinController {
13
 public class MuffinController {
9
 
14
 
10
     private MuffinRepository muffinRepository;
15
     private MuffinRepository muffinRepository;
11
 
16
 
17
+    @Autowired
12
     public ResponseEntity<Iterable<Muffin>> index() {
18
     public ResponseEntity<Iterable<Muffin>> index() {
13
         return new ResponseEntity<>(this.muffinRepository.findAll(), HttpStatus.OK);
19
         return new ResponseEntity<>(this.muffinRepository.findAll(), HttpStatus.OK);
14
     }
20
     }
15
-
21
+    @RequestMapping(value="/muffin", method= RequestMethod.GET)
16
     public ResponseEntity<Muffin> show(Long id) {
22
     public ResponseEntity<Muffin> show(Long id) {
17
         return new ResponseEntity<>(this.muffinRepository.findOne(id), HttpStatus.OK);
23
         return new ResponseEntity<>(this.muffinRepository.findOne(id), HttpStatus.OK);
18
     }
24
     }
19
 
25
 
26
+    @RequestMapping(value = "/muffin", method = RequestMethod.POST)
20
     public ResponseEntity<Muffin> create(Muffin muffin) {
27
     public ResponseEntity<Muffin> create(Muffin muffin) {
21
         return new ResponseEntity<>(this.muffinRepository.save(muffin), HttpStatus.CREATED);
28
         return new ResponseEntity<>(this.muffinRepository.save(muffin), HttpStatus.CREATED);
22
     }
29
     }
23
 
30
 
31
+    @RequestMapping(value = "/muffin/{muffinid}", method = RequestMethod.POST)
24
     public ResponseEntity<Muffin> update(Long id, Muffin muffin) {
32
     public ResponseEntity<Muffin> update(Long id, Muffin muffin) {
25
         Muffin foundMuffin = muffinRepository.findOne(id);
33
         Muffin foundMuffin = muffinRepository.findOne(id);
26
         foundMuffin.setFlavor(muffin.getFlavor());
34
         foundMuffin.setFlavor(muffin.getFlavor());
28
         return new ResponseEntity<>(this.muffinRepository.save(foundMuffin), HttpStatus.OK);
36
         return new ResponseEntity<>(this.muffinRepository.save(foundMuffin), HttpStatus.OK);
29
     }
37
     }
30
 
38
 
39
+    @RequestMapping(value = "/muffin/{muffinid}", method = RequestMethod.DELETE)
31
     public ResponseEntity<Boolean> destroy(Long id) {
40
     public ResponseEntity<Boolean> destroy(Long id) {
32
         this.muffinRepository.delete(id);
41
         this.muffinRepository.delete(id);
33
         return new ResponseEntity<>(true, HttpStatus.OK);
42
         return new ResponseEntity<>(true, HttpStatus.OK);

+ 11
- 0
src/main/java/com/zipcodewilmington/bakery/Models/Baker.java View File

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

+ 10
- 0
src/main/java/com/zipcodewilmington/bakery/Models/Muffin.java View File

1
 package com.zipcodewilmington.bakery.Models;
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
 public class Muffin {
9
 public class Muffin {
4
 
10
 
11
+    @Id
12
+    @GeneratedValue
13
+    @Column(name = "MUFFIN_ID")
5
     private Long id;
14
     private Long id;
6
 
15
 
16
+    @Column(name = "MUFFIN_FLAVOR")
7
     private String flavor;
17
     private String flavor;
8
 
18
 
9
     public Muffin(String flavor) {
19
     public Muffin(String flavor) {