-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuthorController.java
More file actions
42 lines (31 loc) · 1.03 KB
/
Copy pathAuthorController.java
File metadata and controls
42 lines (31 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.spring.neo4j.controller;
import com.spring.neo4j.repository.node.Author;
import com.spring.neo4j.service.AuthorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("author")
public class AuthorController {
private final AuthorService authorService;
@Autowired
public AuthorController(AuthorService authorService) {
this.authorService = authorService;
}
@GetMapping
public List<Author> getAllAuthors(){
return authorService.getAllAuthors();
}
@PostMapping
public Author addAuthor(@RequestBody Author author){
return authorService.addAuthor(author);
}
@PutMapping
public Author updateAuthor(@RequestBody Author author) {
return authorService.updateAuthor(author);
}
@DeleteMapping("/author/{authorId}")
public void deleteAuthor(@PathVariable Long authorId){
authorService.deleteAuthor(authorId);
}
}