浏览代码

first commit

Leon 6 年前
当前提交
8bf78b55c5

二进制
.DS_Store 查看文件


+ 25
- 0
.gitignore 查看文件

@@ -0,0 +1,25 @@
1
+/target/
2
+!.mvn/wrapper/maven-wrapper.jar
3
+
4
+### STS ###
5
+.apt_generated
6
+.classpath
7
+.factorypath
8
+.project
9
+.settings
10
+.springBeans
11
+.sts4-cache
12
+
13
+### IntelliJ IDEA ###
14
+.idea
15
+*.iws
16
+*.iml
17
+*.ipr
18
+
19
+### NetBeans ###
20
+/nbproject/private/
21
+/build/
22
+/nbbuild/
23
+/dist/
24
+/nbdist/
25
+/.nb-gradle/

二进制
.mvn/wrapper/maven-wrapper.jar 查看文件


+ 1
- 0
.mvn/wrapper/maven-wrapper.properties 查看文件

@@ -0,0 +1 @@
1
+distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip

+ 65
- 0
pom.xml 查看文件

@@ -0,0 +1,65 @@
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"
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
+
6
+	<groupId>com.zipcodewilmington</groupId>
7
+	<artifactId>bakery</artifactId>
8
+	<version>0.0.1-SNAPSHOT</version>
9
+	<packaging>jar</packaging>
10
+
11
+	<name>bakery</name>
12
+	<description>Demo project for Spring Boot</description>
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>
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>
26
+
27
+	<dependencies>
28
+		<dependency>
29
+			<groupId>org.springframework.boot</groupId>
30
+			<artifactId>spring-boot-starter</artifactId>
31
+		</dependency>
32
+
33
+		<dependency>
34
+			<groupId>org.springframework.boot</groupId>
35
+			<artifactId>spring-boot-starter-data-rest</artifactId>
36
+		</dependency>
37
+
38
+		<dependency>
39
+			<groupId>org.springframework.boot</groupId>
40
+			<artifactId>spring-boot-starter-web</artifactId>
41
+		</dependency>
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>
54
+
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>
63
+
64
+
65
+</project>

+ 12
- 0
src/main/java/com/zipcodewilmington/bakery/BakeryApplication.java 查看文件

@@ -0,0 +1,12 @@
1
+package com.zipcodewilmington.bakery;
2
+
3
+import org.springframework.boot.SpringApplication;
4
+import org.springframework.boot.autoconfigure.SpringBootApplication;
5
+
6
+@SpringBootApplication
7
+public class BakeryApplication {
8
+
9
+	public static void main(String[] args) {
10
+		SpringApplication.run(BakeryApplication.class, args);
11
+	}
12
+}

+ 37
- 0
src/main/java/com/zipcodewilmington/bakery/Controllers/BakerController.java 查看文件

@@ -0,0 +1,37 @@
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
+
10
+    private BakerRepository bakerRepository;
11
+
12
+    public ResponseEntity<Iterable<Baker>> index() {
13
+        return new ResponseEntity<>(this.bakerRepository.findAll(), HttpStatus.OK);
14
+    }
15
+
16
+    public ResponseEntity<Baker> show(Long id) {
17
+        return new ResponseEntity<>(this.bakerRepository.findOne(id), HttpStatus.OK);
18
+    }
19
+
20
+    public ResponseEntity<Baker> create(Baker baker) {
21
+        return new ResponseEntity<>(this.bakerRepository.save(baker), HttpStatus.CREATED);
22
+    }
23
+
24
+    public ResponseEntity<Baker> update(Long id, Baker baker) {
25
+        Baker foundBaker = bakerRepository.findOne(id);
26
+
27
+        foundBaker.setName(baker.getName());
28
+        foundBaker.setSpecialty(baker.getSpecialty());
29
+
30
+        return new ResponseEntity<>(this.bakerRepository.save(foundBaker), HttpStatus.OK);
31
+    }
32
+
33
+    public ResponseEntity<Boolean> destroy(Long id) {
34
+        this.bakerRepository.delete(id);
35
+        return new ResponseEntity<>(true, HttpStatus.OK);
36
+    }
37
+}

+ 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.findOne(id), 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.findOne(id);
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.delete(id);
33
+        return new ResponseEntity<>(true, HttpStatus.OK);
34
+    }
35
+
36
+}

+ 49
- 0
src/main/java/com/zipcodewilmington/bakery/Models/Baker.java 查看文件

@@ -0,0 +1,49 @@
1
+package com.zipcodewilmington.bakery.Models;
2
+
3
+public class Baker {
4
+    private Long id;
5
+
6
+    private String name;
7
+
8
+    private String employeeId;
9
+
10
+    private String specialty;
11
+
12
+    public Baker(String name, String employeeId, String specialty) {
13
+        this.name = name;
14
+        this.employeeId = employeeId;
15
+        this.specialty = specialty;
16
+    }
17
+
18
+    public Long getId() {
19
+        return id;
20
+    }
21
+
22
+    public void setId(Long id) {
23
+        this.id = id;
24
+    }
25
+
26
+    public String getName() {
27
+        return name;
28
+    }
29
+
30
+    public void setName(String name) {
31
+        this.name = name;
32
+    }
33
+
34
+    public String getEmployeeId() {
35
+        return employeeId;
36
+    }
37
+
38
+    public void setEmployeeId(String employeeId) {
39
+        this.employeeId = employeeId;
40
+    }
41
+
42
+    public String getSpecialty() {
43
+        return specialty;
44
+    }
45
+
46
+    public void setSpecialty(String specialty) {
47
+        this.specialty = specialty;
48
+    }
49
+}

+ 28
- 0
src/main/java/com/zipcodewilmington/bakery/Models/Muffin.java 查看文件

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

+ 7
- 0
src/main/java/com/zipcodewilmington/bakery/Repositories/BakerRepository.java 查看文件

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

+ 7
- 0
src/main/java/com/zipcodewilmington/bakery/Repositories/MuffinRepository.java 查看文件

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

+ 0
- 0
src/main/resources/application.properties 查看文件


+ 16
- 0
src/test/java/com/zipcodewilmington/bakery/BakeryApplicationTests.java 查看文件

@@ -0,0 +1,16 @@
1
+package com.zipcodewilmington.bakery;
2
+
3
+import org.junit.Test;
4
+import org.junit.runner.RunWith;
5
+import org.springframework.boot.test.context.SpringBootTest;
6
+import org.springframework.test.context.junit4.SpringRunner;
7
+
8
+@RunWith(SpringRunner.class)
9
+@SpringBootTest
10
+public class BakeryApplicationTests {
11
+
12
+	@Test
13
+	public void contextLoads() {
14
+	}
15
+
16
+}