Bladeren bron

Simplified BeerController

Matt Raible 7 jaren geleden
bovenliggende
commit
8acd621f9a
1 gewijzigde bestanden met toevoegingen van 2 en 7 verwijderingen
  1. 2
    7
      server/src/main/java/com/example/beer/BeerController.java

+ 2
- 7
server/src/main/java/com/example/beer/BeerController.java Bestand weergeven

19
 
19
 
20
     @GetMapping("/good-beers")
20
     @GetMapping("/good-beers")
21
     @CrossOrigin(origins = {"http://localhost:8100","file://"})
21
     @CrossOrigin(origins = {"http://localhost:8100","file://"})
22
-    public Collection<Map<String, String>> goodBeers() {
22
+    public Collection<Beer> goodBeers() {
23
 
23
 
24
         return repository.findAll().stream()
24
         return repository.findAll().stream()
25
                 .filter(this::isGreat)
25
                 .filter(this::isGreat)
26
-                .map(b -> {
27
-                    Map<String, String> m = new HashMap<>();
28
-                    m.put("id", b.getId().toString());
29
-                    m.put("name", b.getName());
30
-                    return m;
31
-                }).collect(Collectors.toList());
26
+                .collect(Collectors.toList());
32
     }
27
     }
33
 
28
 
34
     private boolean isGreat(Beer beer) {
29
     private boolean isGreat(Beer beer) {