-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathPostCommentController.java
More file actions
51 lines (44 loc) · 2.2 KB
/
PostCommentController.java
File metadata and controls
51 lines (44 loc) · 2.2 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
43
44
45
46
47
48
49
50
51
package clap.server.adapter.inbound.web.comment;
import clap.server.adapter.inbound.security.SecurityUserDetails;
import clap.server.adapter.inbound.web.dto.task.PostAndEditCommentRequest;
import clap.server.application.port.inbound.comment.PostCommentUsecase;
import clap.server.common.annotation.architecture.WebAdapter;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@Tag(name = "02. Task", description = "작업 생성/수정 API")
@WebAdapter
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/comment")
public class PostCommentController {
private final PostCommentUsecase postCommentUsecase;
@Operation(summary = "댓글 작성")
@Parameter(name = "taskId", description = "댓글 작성할 작업 고유 ID", required = true, in = ParameterIn.PATH)
@PostMapping("/{taskId}")
@Secured({"ROLE_MANAGER", "ROLE_USER"})
public void createComment(
@AuthenticationPrincipal SecurityUserDetails userInfo,
@PathVariable Long taskId,
@RequestBody(required = true) PostAndEditCommentRequest request){
postCommentUsecase.save(userInfo.getUserId(), taskId, request);
}
@Operation(summary = "댓글 작성(첨부 파일)")
@Parameter(name = "taskId", description = "댓글 작성할 작업 고유 ID", required = true, in = ParameterIn.PATH)
@PostMapping("/attachment/{taskId}")
@Secured({"ROLE_MANAGER", "ROLE_USER"})
public void createAttachmentComment(
@AuthenticationPrincipal SecurityUserDetails userInfo,
@PathVariable Long taskId,
@RequestPart(name = "attachment") @NotNull MultipartFile attachment) {
postCommentUsecase.saveCommentAttachment(userInfo.getUserId(), taskId, attachment);
}
}