7
7
import org .springframework .web .bind .annotation .*;
8
8
9
9
import javax .inject .Inject ;
10
- import javax .persistence .EntityManager ;
11
- import javax .persistence .PersistenceContext ;
12
10
import java .util .Collection ;
13
11
14
12
@ RestController
@@ -17,9 +15,6 @@ public class BookRestController {
17
15
18
16
private BookRepository repository ;
19
17
20
- @ PersistenceContext
21
- private EntityManager entityManager ;
22
-
23
18
@ Inject
24
19
public void setRepository (BookRepository repository ) {
25
20
this .repository = repository ;
@@ -38,15 +33,15 @@ public ResponseEntity<Collection<Book>> getAllBooks() {
38
33
}
39
34
40
35
@ RequestMapping (
41
- method = RequestMethod . GET ,
42
- value = "/{id}" )
36
+ value = "/{id}" ,
37
+ method = RequestMethod . GET )
43
38
public ResponseEntity <Book > getBookWithId (@ PathVariable Long id ) {
44
39
return new ResponseEntity <>(repository .findOne (id ), HttpStatus .OK );
45
40
}
46
41
47
42
@ RequestMapping (
48
- method = RequestMethod . GET ,
49
- params = { "name" } )
43
+ params = { "name" } ,
44
+ method = RequestMethod . GET )
50
45
public ResponseEntity <Collection <Book >> findBookWithName (@ RequestParam (value = "name" ) String name ) {
51
46
return new ResponseEntity <>(repository .findByName (name ), HttpStatus .OK );
52
47
}
@@ -65,8 +60,8 @@ public ResponseEntity<Book> updateUserFromDB(@PathVariable("id") long id, @Reque
65
60
}
66
61
67
62
@ RequestMapping (
68
- method = RequestMethod . DELETE ,
69
- value = "/{id}" )
63
+ value = "/{id}" ,
64
+ method = RequestMethod . DELETE )
70
65
public void deleteBookWithId (@ PathVariable Long id ) {
71
66
repository .delete (id );
72
67
}
0 commit comments