Просмотр исходного кода

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

Demetrius Murray 5 лет назад
Родитель
Сommit
e7f44cffe8

+ 75
- 0
pom.xml Просмотреть файл

@@ -1,4 +1,5 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2
+<<<<<<< HEAD
2 3
 <project xmlns="http://maven.apache.org/POM/4.0.0"
3 4
 		 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 5
 		 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -56,6 +57,80 @@
56 57
 			<version>1</version>
57 58
 		</dependency>
58 59
 	</dependencies>
60
+=======
61
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
62
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
63
+    <modelVersion>4.0.0</modelVersion>
64
+
65
+    <groupId>com.zipcodewilmington</groupId>
66
+    <artifactId>bakery</artifactId>
67
+    <version>0.0.1-SNAPSHOT</version>
68
+    <packaging>jar</packaging>
69
+
70
+    <name>bakery</name>
71
+    <description>Demo project for Spring Boot</description>
72
+
73
+    <parent>
74
+        <groupId>org.springframework.boot</groupId>
75
+        <artifactId>spring-boot-starter-parent</artifactId>
76
+        <version>2.0.4.RELEASE</version>
77
+        <relativePath/> <!-- lookup parent from repository -->
78
+    </parent>
79
+
80
+    <properties>
81
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
82
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
83
+        <java.version>1.8</java.version>
84
+    </properties>
85
+
86
+    <dependencies>
87
+        <dependency>
88
+            <groupId>org.springframework.boot</groupId>
89
+            <artifactId>spring-boot-starter</artifactId>
90
+        </dependency>
91
+
92
+        <dependency>
93
+            <groupId>org.springframework.boot</groupId>
94
+            <artifactId>spring-boot-starter-data-rest</artifactId>
95
+        </dependency>
96
+
97
+        <dependency>
98
+            <groupId>org.springframework.boot</groupId>
99
+            <artifactId>spring-boot-starter-web</artifactId>
100
+        </dependency>
101
+
102
+        <dependency>
103
+            <groupId>org.springframework.boot</groupId>
104
+            <artifactId>spring-boot-starter-test</artifactId>
105
+            <scope>test</scope>
106
+        </dependency>
107
+        <dependency>
108
+            <groupId>org.springframework.data</groupId>
109
+            <artifactId>spring-data-commons</artifactId>
110
+        </dependency>
111
+        <dependency>
112
+            <groupId>org.springframework.boot</groupId>
113
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
114
+        </dependency>
115
+        <dependency>
116
+            <groupId>com.h2database</groupId>
117
+            <artifactId>h2</artifactId>
118
+        </dependency>
119
+        <dependency>
120
+            <groupId>org.springframework.boot</groupId>
121
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
122
+        </dependency>
123
+    </dependencies>
124
+
125
+    <build>
126
+        <plugins>
127
+            <plugin>
128
+                <groupId>org.springframework.boot</groupId>
129
+                <artifactId>spring-boot-maven-plugin</artifactId>
130
+            </plugin>
131
+        </plugins>
132
+    </build>
133
+>>>>>>> 1356254de500f16124e3fe66a4b3ab488374a38d
59 134
 
60 135
 
61 136
 </project>

Двоичные данные
src/main/java/com/zipcodewilmington/bakery/.DS_Store Просмотреть файл


+ 36
- 0
src/main/java/com/zipcodewilmington/bakery/Controllers/BakerController.java Просмотреть файл

@@ -0,0 +1,36 @@
1
+package com.zipcodewilmington.bakery.Controllers;
2
+
3
+import com.zipcodewilmington.bakery.Models.Baker;
4
+import com.zipcodewilmington.bakery.Repositories.BakerRepository;
5
+import org.springframework.http.HttpStatus;
6
+import org.springframework.http.ResponseEntity;
7
+
8
+public class BakerController {
9
+    private BakerRepository bakerRepository;
10
+
11
+    public ResponseEntity<Iterable<Baker>> index() {
12
+        return new ResponseEntity<>(this.bakerRepository.findAll(), HttpStatus.OK);
13
+    }
14
+
15
+    public ResponseEntity<Baker> show(Long id) {
16
+        return new ResponseEntity<>(this.bakerRepository.findById(id).get(), HttpStatus.OK);
17
+    }
18
+
19
+    public ResponseEntity<Baker> create(Baker baker) {
20
+        return new ResponseEntity<>(this.bakerRepository.save(baker), HttpStatus.CREATED);
21
+    }
22
+
23
+    public ResponseEntity<Baker> update(Long id, Baker baker) {
24
+        Baker foundBaker = bakerRepository.findById(id).get();
25
+
26
+        foundBaker.setName(baker.getName());
27
+        foundBaker.setSpecialty(baker.getSpecialty());
28
+
29
+        return new ResponseEntity<>(this.bakerRepository.save(foundBaker), HttpStatus.OK);
30
+    }
31
+
32
+    public ResponseEntity<Boolean> destroy(Long id) {
33
+        this.bakerRepository.findById(id).get();
34
+        return new ResponseEntity<>(true, HttpStatus.OK);
35
+    }
36
+}

+ 36
- 0
src/main/java/com/zipcodewilmington/bakery/Controllers/MuffinController.java Просмотреть файл

@@ -0,0 +1,36 @@
1
+package com.zipcodewilmington.bakery.Controllers;
2
+
3
+import com.zipcodewilmington.bakery.Models.Muffin;
4
+import com.zipcodewilmington.bakery.Repositories.MuffinRepository;
5
+import org.springframework.http.HttpStatus;
6
+import org.springframework.http.ResponseEntity;
7
+
8
+public class MuffinController {
9
+
10
+    private MuffinRepository muffinRepository;
11
+
12
+    public ResponseEntity<Iterable<Muffin>> index() {
13
+        return new ResponseEntity<>(this.muffinRepository.findAll(), HttpStatus.OK);
14
+    }
15
+
16
+    public ResponseEntity<Muffin> show(Long id) {
17
+        return new ResponseEntity<>(this.muffinRepository.findById(id).get(), HttpStatus.OK);
18
+    }
19
+
20
+    public ResponseEntity<Muffin> create(Muffin muffin) {
21
+        return new ResponseEntity<>(this.muffinRepository.save(muffin), HttpStatus.CREATED);
22
+    }
23
+
24
+    public ResponseEntity<Muffin> update(Long id, Muffin muffin) {
25
+        Muffin foundMuffin = muffinRepository.findById(id).get();
26
+        foundMuffin.setFlavor(muffin.getFlavor());
27
+
28
+        return new ResponseEntity<>(this.muffinRepository.save(foundMuffin), HttpStatus.OK);
29
+    }
30
+
31
+    public ResponseEntity<Boolean> destroy(Long id) {
32
+        this.muffinRepository.deleteById(id);
33
+        return new ResponseEntity<>(true, HttpStatus.OK);
34
+    }
35
+
36
+}

+ 27
- 0
src/main/java/com/zipcodewilmington/bakery/Models/Muffin.java Просмотреть файл

@@ -0,0 +1,27 @@
1
+package com.zipcodewilmington.bakery.Models;
2
+
3
+public class Muffin {
4
+    private Long id;
5
+
6
+    private String flavor;
7
+
8
+    public Muffin(String flavor) {
9
+        this.flavor = flavor;
10
+    }
11
+
12
+    public Long getId() {
13
+        return id;
14
+    }
15
+
16
+    public void setId(Long id) {
17
+        this.id = id;
18
+    }
19
+
20
+    public String getFlavor() {
21
+        return flavor;
22
+    }
23
+
24
+    public void setFlavor(String flavor) {
25
+        this.flavor = flavor;
26
+    }
27
+}

+ 8
- 0
src/main/java/com/zipcodewilmington/bakery/Repositories/BakerRepository.java Просмотреть файл

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

+ 8
- 0
src/main/java/com/zipcodewilmington/bakery/Repositories/MuffinRepository.java Просмотреть файл

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