FooController refactor (#1345)
This commit is contained in:
parent
3de9a69c62
commit
e46484df4c
|
@ -3,8 +3,6 @@ package org.baeldung.boot.service;
|
||||||
import org.baeldung.boot.components.FooService;
|
import org.baeldung.boot.components.FooService;
|
||||||
import org.baeldung.boot.model.Foo;
|
import org.baeldung.boot.model.Foo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
@ -17,18 +15,12 @@ public class FooController {
|
||||||
private FooService fooService;
|
private FooService fooService;
|
||||||
|
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public ResponseEntity<?> getFooWithId(@PathVariable Integer id) throws Exception {
|
public Foo getFooWithId(@PathVariable Integer id) throws Exception {
|
||||||
|
return fooService.getFooWithId(id);
|
||||||
Foo foo = fooService.getFooWithId(id);
|
|
||||||
|
|
||||||
return new ResponseEntity<>(foo, HttpStatus.OK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/")
|
@GetMapping("/")
|
||||||
public ResponseEntity<?> getFooWithName(@RequestParam String name) throws Exception {
|
public Foo getFooWithName(@RequestParam String name) throws Exception {
|
||||||
|
return fooService.getFooWithName(name);
|
||||||
Foo foo = fooService.getFooWithName(name);
|
|
||||||
|
|
||||||
return new ResponseEntity<>(foo, HttpStatus.OK);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue