Parcourir la source

Revert "uhhh"

This reverts commit 2ca439bd842a9d5ab2315919c28935cf42f491ea.
Trinh Tong il y a 6 ans
Parent
révision
4be5a90cc6

BIN
.DS_Store Voir le fichier


+ 12
- 0
src/main/java/com/zipcodewilmington/bakery/BakeryApplication.java Voir le fichier

@@ -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 Voir le fichier

@@ -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 Voir le fichier

@@ -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 Voir le fichier

@@ -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 Voir le fichier

@@ -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 Voir le fichier

@@ -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 Voir le fichier

@@ -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
+}