-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat] 프롬프트 상세 조회 및 댓글 CRUD API 계약 및 Swagger 명세 작성 #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
efaeda8
feat: 프롬프트 상세 조회 및 댓글 CRUD Swagger 명세 추가
KunHeeLee7 79446f5
refactor: Swagger 오류 응답 문서화 공통화
KunHeeLee7 c910a57
refactor: 작성자 및 프롬프트 설명 필드명 명확화
KunHeeLee7 94faf45
feat: 프롬프트 상세 조회 사용자 상호작용 상태 추가
KunHeeLee7 6eb9809
feat: 댓글 응답에 프롬프트 작성자 여부 추가
KunHeeLee7 d5b7087
Merge remote-tracking branch 'origin/develop' into feat/#29-prompt-co…
Hanharam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
src/main/java/com/promsearch/community/interfaces/CommentController.java
This file contains hidden or 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,77 @@ | ||
| package com.promsearch.community.interfaces; | ||
|
|
||
| import com.promsearch.community.interfaces.docs.CommentControllerDocs; | ||
| import com.promsearch.community.interfaces.dto.request.CreateCommentRequest; | ||
| import com.promsearch.community.interfaces.dto.request.UpdateCommentRequest; | ||
| import com.promsearch.community.interfaces.dto.response.CommentListResponse; | ||
| import com.promsearch.community.interfaces.dto.response.CommentReplyResponse; | ||
| import com.promsearch.community.interfaces.dto.response.CommentResponse; | ||
| import com.promsearch.global.exception.NotImplementedException; | ||
| import com.promsearch.global.response.ApiResponse; | ||
| import com.promsearch.global.security.AuthenticatedUserPrincipal; | ||
| import jakarta.validation.Valid; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
| import org.springframework.validation.annotation.Validated; | ||
| import org.springframework.web.bind.annotation.DeleteMapping; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.PatchMapping; | ||
| 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; | ||
|
|
||
| @Validated | ||
| @RestController | ||
| @RequestMapping("/api/v1") | ||
| public class CommentController implements CommentControllerDocs { | ||
|
|
||
| @GetMapping("/prompts/{promptId}/comments") | ||
| @Override | ||
| public ApiResponse<CommentListResponse> getComments( | ||
| @PathVariable Long promptId, | ||
| @AuthenticationPrincipal AuthenticatedUserPrincipal user | ||
| ) { | ||
| throw new NotImplementedException("댓글 목록 조회 기능은 아직 구현되지 않았습니다."); | ||
| } | ||
|
|
||
| @PostMapping("/prompts/{promptId}/comments") | ||
| @Override | ||
| public ResponseEntity<ApiResponse<CommentResponse>> createComment( | ||
| @PathVariable Long promptId, | ||
| @AuthenticationPrincipal AuthenticatedUserPrincipal user, | ||
| @Valid @RequestBody CreateCommentRequest request | ||
| ) { | ||
| throw new NotImplementedException("댓글 작성 기능은 아직 구현되지 않았습니다."); | ||
| } | ||
|
|
||
| @PatchMapping("/comments/{commentId}") | ||
| @Override | ||
| public ApiResponse<CommentResponse> updateComment( | ||
| @PathVariable Long commentId, | ||
| @AuthenticationPrincipal AuthenticatedUserPrincipal user, | ||
| @Valid @RequestBody UpdateCommentRequest request | ||
| ) { | ||
| throw new NotImplementedException("댓글 수정 기능은 아직 구현되지 않았습니다."); | ||
| } | ||
|
|
||
| @DeleteMapping("/comments/{commentId}") | ||
| @Override | ||
| public ApiResponse<Void> deleteComment( | ||
| @PathVariable Long commentId, | ||
| @AuthenticationPrincipal AuthenticatedUserPrincipal user | ||
| ) { | ||
| throw new NotImplementedException("댓글 삭제 기능은 아직 구현되지 않았습니다."); | ||
| } | ||
|
|
||
| @PostMapping("/comments/{commentId}/replies") | ||
| @Override | ||
| public ResponseEntity<ApiResponse<CommentReplyResponse>> createReply( | ||
| @PathVariable Long commentId, | ||
| @AuthenticationPrincipal AuthenticatedUserPrincipal user, | ||
| @Valid @RequestBody CreateCommentRequest request | ||
| ) { | ||
| throw new NotImplementedException("대댓글 작성 기능은 아직 구현되지 않았습니다."); | ||
| } | ||
| } |
296 changes: 296 additions & 0 deletions
296
src/main/java/com/promsearch/community/interfaces/docs/CommentControllerDocs.java
Large diffs are not rendered by default.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
src/main/java/com/promsearch/community/interfaces/dto/request/CreateCommentRequest.java
This file contains hidden or 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,12 @@ | ||
| package com.promsearch.community.interfaces.dto.request; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.validation.constraints.NotBlank; | ||
|
|
||
| @Schema(description = "댓글 또는 대댓글 작성 요청") | ||
| public record CreateCommentRequest( | ||
| @Schema(description = "댓글 내용", example = "좋은 프롬프트네요.") | ||
| @NotBlank(message = "content must not be blank") | ||
| String content | ||
| ) { | ||
| } |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/promsearch/community/interfaces/dto/request/UpdateCommentRequest.java
This file contains hidden or 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,12 @@ | ||
| package com.promsearch.community.interfaces.dto.request; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.validation.constraints.NotBlank; | ||
|
|
||
| @Schema(description = "댓글 수정 요청") | ||
| public record UpdateCommentRequest( | ||
| @Schema(description = "수정할 댓글 내용", example = "수정된 댓글 내용입니다.") | ||
| @NotBlank(message = "content must not be blank") | ||
| String content | ||
| ) { | ||
| } |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/promsearch/community/interfaces/dto/response/CommentAuthorResponse.java
This file contains hidden or 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,20 @@ | ||
| package com.promsearch.community.interfaces.dto.response; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
|
|
||
| @Schema(description = "댓글 작성자 공개 정보") | ||
| public record CommentAuthorResponse( | ||
| @Schema(description = "작성자 ID", example = "8") | ||
| Long userId, | ||
|
|
||
| @Schema(description = "작성자 닉네임", example = "홍길동") | ||
| String nickname, | ||
|
|
||
| @Schema( | ||
| description = "작성자 프로필 이미지 URL", | ||
| example = "https://cdn.promsearch.com/profiles/8.jpg", | ||
| nullable = true | ||
| ) | ||
| String profileImageUrl | ||
| ) { | ||
| } |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/promsearch/community/interfaces/dto/response/CommentListResponse.java
This file contains hidden or 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,11 @@ | ||
| package com.promsearch.community.interfaces.dto.response; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import java.util.List; | ||
|
|
||
| @Schema(description = "페이지네이션 없이 전체 댓글을 반환하는 목록 응답") | ||
| public record CommentListResponse( | ||
| @Schema(description = "작성 시간 내림차순으로 정렬된 최상위 댓글 목록") | ||
| List<CommentResponse> comments | ||
| ) { | ||
| } |
36 changes: 36 additions & 0 deletions
36
src/main/java/com/promsearch/community/interfaces/dto/response/CommentReplyResponse.java
This file contains hidden or 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,36 @@ | ||
| package com.promsearch.community.interfaces.dto.response; | ||
|
|
||
| import com.promsearch.community.domain.enums.CommentStatus; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import java.time.Instant; | ||
|
|
||
| @Schema(description = "대댓글 응답") | ||
| public record CommentReplyResponse( | ||
| @Schema(description = "대댓글 ID", example = "102") | ||
| Long commentId, | ||
|
|
||
| @Schema(description = "부모 댓글 ID", example = "101") | ||
| Long parentCommentId, | ||
|
|
||
| @Schema(description = "작성자 정보") | ||
| CommentAuthorResponse author, | ||
|
|
||
| @Schema(description = "대댓글 내용", example = "저도 그렇게 생각합니다.") | ||
| String content, | ||
|
|
||
| @Schema(description = "대댓글 상태", example = "ACTIVE") | ||
| CommentStatus status, | ||
|
|
||
| @Schema(description = "현재 로그인 사용자가 작성한 대댓글인지 여부", example = "true") | ||
| boolean mine, | ||
|
|
||
| @Schema(description = "프롬프트 작성자가 작성한 대댓글인지 여부", example = "false") | ||
| boolean promptAuthor, | ||
|
|
||
| @Schema(description = "작성 시각", example = "2026-07-23T03:10:00Z") | ||
| Instant createdAt, | ||
|
|
||
| @Schema(description = "수정 시각", example = "2026-07-23T03:10:00Z") | ||
| Instant updatedAt | ||
| ) { | ||
| } |
40 changes: 40 additions & 0 deletions
40
src/main/java/com/promsearch/community/interfaces/dto/response/CommentResponse.java
This file contains hidden or 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,40 @@ | ||
| package com.promsearch.community.interfaces.dto.response; | ||
|
|
||
| import com.promsearch.community.domain.enums.CommentStatus; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import java.time.Instant; | ||
| import java.util.List; | ||
|
|
||
| @Schema(description = "댓글 및 대댓글 응답") | ||
| public record CommentResponse( | ||
| @Schema(description = "댓글 ID", example = "101") | ||
| Long commentId, | ||
|
|
||
| @Schema(description = "부모 댓글 ID. 최상위 댓글이면 null입니다.", example = "100", nullable = true) | ||
| Long parentCommentId, | ||
|
|
||
| @Schema(description = "작성자 정보") | ||
| CommentAuthorResponse author, | ||
|
|
||
| @Schema(description = "댓글 내용", example = "좋은 프롬프트네요.") | ||
| String content, | ||
|
|
||
| @Schema(description = "댓글 상태", example = "ACTIVE") | ||
| CommentStatus status, | ||
|
|
||
| @Schema(description = "현재 로그인 사용자가 작성한 댓글인지 여부", example = "true") | ||
| boolean mine, | ||
|
|
||
| @Schema(description = "프롬프트 작성자가 작성한 댓글인지 여부", example = "false") | ||
| boolean promptAuthor, | ||
|
|
||
| @Schema(description = "작성 시각", example = "2026-07-23T01:30:00Z") | ||
| Instant createdAt, | ||
|
|
||
| @Schema(description = "수정 시각", example = "2026-07-23T01:30:00Z") | ||
| Instant updatedAt, | ||
|
|
||
| @Schema(description = "작성 시간 내림차순으로 정렬된 대댓글 목록") | ||
| List<CommentReplyResponse> replies | ||
| ) { | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Figma 댓글 컴포넌트에는 프롬프트 작성자의 댓글임을 나타내는 “작성자” 배지가 있고
mine은 로그인 사용자 본인의 댓글인지만 나타내고 있습니다.그래서 boolean 형식의 필드를 추가해서 작성자 댓글인 것을 나타내면 좋을 것 같습니다!
아니면 상세 응답의
prompt.author.userId와comment.author.userId를 프론트가 비교하는 방식으로 처리할지, 댓글 응답에promptAuthorboolean을 제공할지 정하는 것도 좋을 것 같습니다!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
프론트에서 작성자 ID를 비교하는 방식도 가능하지만, 댓글 API만으로 UI 상태를 명확히 판단할 수 있도록 백엔드에서 제공하는 방향으로 반영했습니다. 기존 mine은 로그인 사용자 본인의 댓글 여부로 유지하고, 프롬프트 작성자의 댓글 여부를 나타내는 promptAuthor 필드를 댓글 및 대댓글 응답에 추가했습니다. 놓쳤던 세부 사항까지 꼼꼼하게 확인해 주셔서 감사합니다!