-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathCommentActionController.java
More file actions
31 lines (27 loc) · 1.07 KB
/
CommentActionController.java
File metadata and controls
31 lines (27 loc) · 1.07 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
package com.example.devSns.controller;
import com.example.devSns.dto.CommentResponse;
import com.example.devSns.dto.CommentUpdateRequest;
import com.example.devSns.entity.Comment;
import com.example.devSns.service.CommentService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/comments")
public class CommentActionController {
private final CommentService CommentService;
public CommentActionController(CommentService commentService){
this.CommentService = commentService;
}
@DeleteMapping("/{commentId}")
public void deleteComment(@PathVariable Long commentId) {
CommentService.deleteComment(commentId);
}
@PatchMapping("/{commentId}")
public ResponseEntity<CommentResponse> updateComment(
@PathVariable Long commentId,
@RequestBody CommentUpdateRequest request
) {
Comment updated = CommentService.UpdateComment(commentId, request.getContent());
return ResponseEntity.ok(new CommentResponse(updated));
}
}