forked from codesquad-members-2024/issue-tracker
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 사용자가 작성한 정보로 코멘트 생성하고 id를 지정하여 코멘트 상세정보 반환
- Loading branch information
1 parent
61102e9
commit 4fcd4e5
Showing
7 changed files
with
86 additions
and
3 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
be/issue-tracker/src/main/java/com/issuetracker/comment/CommentController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.issuetracker.comment; | ||
|
||
import com.issuetracker.comment.dto.CommentCreateRequest; | ||
import com.issuetracker.comment.dto.CommentDetailDto; | ||
import com.issuetracker.comment.service.CommentService; | ||
import jakarta.validation.Valid; | ||
import java.net.URI; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
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; | ||
|
||
@RequestMapping("/api/comments") | ||
@RequiredArgsConstructor | ||
@RestController | ||
public class CommentController { | ||
private final CommentService commentService; | ||
|
||
@PostMapping | ||
public ResponseEntity<CommentDetailDto> createComment( | ||
@Valid @RequestBody CommentCreateRequest commentCreateRequest) { | ||
CommentDetailDto commentDetailDto = commentService.createComment(commentCreateRequest); | ||
|
||
URI location = URI.create(String.format("/api/comments/%s", commentDetailDto.getId())); | ||
return ResponseEntity.created(location).body(commentDetailDto); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
be/issue-tracker/src/main/java/com/issuetracker/comment/dto/CommentCreateRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.issuetracker.comment.dto; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
@Getter | ||
public class CommentCreateRequest { | ||
@NotBlank | ||
private final String content; | ||
@NotNull | ||
private final Long issueId; | ||
@NotNull | ||
private final String writerId; // 현재 로그인 유지 기능이 없으므로 해당 데이터 주입받아야함. | ||
private final Long fileId; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters