-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPostController.java
More file actions
32 lines (26 loc) · 1 KB
/
PostController.java
File metadata and controls
32 lines (26 loc) · 1 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
package demo.jacoco.api.controller;
import demo.jacoco.api.dto.PostCreateRequest;
import demo.jacoco.api.dto.PostInfoResponse;
import demo.jacoco.api.service.PostService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/posts")
public class PostController {
private final PostService postService;
public PostController(PostService postService) {
this.postService = postService;
}
@PostMapping
public void createPost(@RequestBody PostCreateRequest request) {
postService.createPost(request);
}
@GetMapping("/{id}")
public PostInfoResponse getPost(@PathVariable Long id){
return postService.getPost(id);
}
}