浏览代码

Simplified BeerController

Matt Raible 7 年前
父节点
当前提交
8acd621f9a
共有 1 个文件被更改,包括 2 次插入7 次删除
  1. 2
    7
      server/src/main/java/com/example/beer/BeerController.java

+ 2
- 7
server/src/main/java/com/example/beer/BeerController.java 查看文件

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) {