-
Notifications
You must be signed in to change notification settings - Fork 0
[Hotfix] 댓글 생성시 댓글 조회와 같은 형식으로 response 반환 #238
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
12 commits
Select commit
Hold shift + click to select a range
98a3b42
[hotfix] 댓글 생성시 댓글 조회와 똑같은 형식으로 response 반환 (#228)
hd0rable 475e4d4
[hotfix] 댓글 생성시 댓글 조회와 똑같은 형식으로 response 반환 (#228)
hd0rable 1525d70
[hotfix] 댓글 생성시 댓글 조회와 똑같은 형식으로 response 반환 (#228)
hd0rable 2b6d4ad
[hotfix] 댓글 생성시 댓글 조회와 똑같은 형식으로 response 반환 (#228)
hd0rable 7e18927
[hotfix] 댓글 생성시 댓글 조회와 똑같은 형식으로 response 반환 (#228)
hd0rable f6efc13
[hotfix] CommentQueryMapper에 CommentCreateResponse 매퍼 추가 (#228)
hd0rable f575165
[feat] CommentQueryPersistenceAdapter에 findRootCommentById,findChild…
hd0rable ccb99cb
[feat] CommentQueryPort에 findRootCommentById,findChildCommentById 추가…
hd0rable 6082d5e
[feat] CommentQueryRepository에 findRootCommentById,findChildCommentB…
hd0rable 36fbaa2
[feat] CommentQueryRepositoryImpl에 findRootCommentById,findChildComm…
hd0rable 47e1f1a
Merge remote-tracking branch 'origin/develop' into hotfix/#228-commen…
hd0rable fb17d32
Merge remote-tracking branch 'origin/develop' into hotfix/#228-commen…
hd0rable 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
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
35 changes: 35 additions & 0 deletions
35
src/main/java/konkuk/thip/comment/adapter/in/web/response/CommentCreateResponse.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,35 @@ | ||
| package konkuk.thip.comment.adapter.in.web.response; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public record CommentCreateResponse( | ||
| Long commentId, | ||
| Long creatorId, | ||
| String creatorProfileImageUrl, | ||
| String creatorNickname, | ||
| String aliasName, | ||
| String aliasColor, | ||
| String postDate, // 댓글 작성 시각 (~ 전 형식) | ||
| String content, | ||
| int likeCount, | ||
| boolean isLike, | ||
| boolean isDeleted, // 삭제된 댓글인지 아닌지 | ||
| boolean isWriter, | ||
| List<ReplyCommentCreateDto> replyList | ||
| ) { | ||
| public record ReplyCommentCreateDto( | ||
| Long commentId, | ||
| String parentCommentCreatorNickname, | ||
| Long creatorId, | ||
| String creatorProfileImageUrl, | ||
| String creatorNickname, | ||
| String aliasName, | ||
| String aliasColor, | ||
| String postDate, // 댓글 작성 시각 (~ 전 형식) | ||
| String content, | ||
| int likeCount, | ||
| boolean isLike, | ||
| boolean isWriter | ||
| ) {} | ||
|
|
||
| } |
7 changes: 0 additions & 7 deletions
7
src/main/java/konkuk/thip/comment/adapter/in/web/response/CommentIdResponse.java
This file was deleted.
Oops, something went wrong.
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
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
3 changes: 2 additions & 1 deletion
3
src/main/java/konkuk/thip/comment/application/port/in/CommentCreateUseCase.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 |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| package konkuk.thip.comment.application.port.in; | ||
|
|
||
| import konkuk.thip.comment.adapter.in.web.response.CommentCreateResponse; | ||
| import konkuk.thip.comment.application.port.in.dto.CommentCreateCommand; | ||
|
|
||
| public interface CommentCreateUseCase { | ||
| Long createComment(CommentCreateCommand command); | ||
| CommentCreateResponse createComment(CommentCreateCommand command); | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,13 @@ | ||
| package konkuk.thip.comment.application.service; | ||
|
|
||
| import konkuk.thip.comment.adapter.in.web.response.CommentCreateResponse; | ||
| import konkuk.thip.comment.application.mapper.CommentQueryMapper; | ||
| import konkuk.thip.comment.application.port.in.CommentCreateUseCase; | ||
| import konkuk.thip.comment.application.port.in.dto.CommentCreateCommand; | ||
| import konkuk.thip.comment.application.port.out.CommentCommandPort; | ||
| import konkuk.thip.comment.application.port.out.CommentLikeQueryPort; | ||
| import konkuk.thip.comment.application.port.out.CommentQueryPort; | ||
| import konkuk.thip.comment.application.port.out.dto.CommentQueryDto; | ||
| import konkuk.thip.comment.application.service.validator.CommentAuthorizationValidator; | ||
| import konkuk.thip.comment.domain.Comment; | ||
| import konkuk.thip.common.exception.InvalidStateException; | ||
|
|
@@ -21,13 +26,17 @@ | |
| public class CommentCreateService implements CommentCreateUseCase { | ||
|
|
||
| private final CommentCommandPort commentCommandPort; | ||
| private final CommentQueryPort commentQueryPort; | ||
| private final CommentLikeQueryPort commentLikeQueryPort; | ||
| private final CommentQueryMapper commentQueryMapper; | ||
|
|
||
|
|
||
| private final PostHandler postHandler; | ||
| private final CommentAuthorizationValidator commentAuthorizationValidator; | ||
|
|
||
| @Override | ||
| @Transactional | ||
| public Long createComment(CommentCreateCommand command) { | ||
| public CommentCreateResponse createComment(CommentCreateCommand command) { | ||
|
|
||
| // 1. 댓글/답글 생성 선행검증 및 작성하려는 게시글 타입 검증 | ||
| Comment.validateCommentCreate(command.isReplyRequest(), command.parentId()); | ||
|
|
@@ -42,7 +51,7 @@ public Long createComment(CommentCreateCommand command) { | |
| // TODO 기록 및 투표: 모임방의 내 게시글에 대한 댓글, 내 댓글에 대한 답글 알림 전송 | ||
|
|
||
| // 3. 댓글 생성 | ||
| Long commentId = createCommentDomain(command); | ||
| Long savedCommentId = createCommentDomain(command); | ||
|
|
||
| //TODO 게시물의 댓글 수 증가/감소 동시성 제어 로직 추가해야됨 | ||
|
|
||
|
|
@@ -52,7 +61,20 @@ public Long createComment(CommentCreateCommand command) { | |
| // 4-2 Jpa엔티티 게시물 댓글 수 증가 | ||
| postHandler.updatePost(type, post); | ||
|
|
||
| return commentId; | ||
| // 5. 매퍼로 DTO 변환 후 반환 | ||
| if (command.isReplyRequest()) { | ||
| // 부모 댓글 조회 | ||
| CommentQueryDto parentCommentDto = commentQueryPort.findRootCommentById(command.parentId()); | ||
| // 사용자 부모 댓글 좋아요 여부 조회 | ||
| boolean isLikedParentComment = commentLikeQueryPort.isLikedCommentByUser(command.userId(),parentCommentDto.commentId()); | ||
|
|
||
| CommentQueryDto savedReplyCommentDto = commentQueryPort.findChildCommentById(command.parentId(), savedCommentId); | ||
| return commentQueryMapper.toRootCommentResponseWithChildren(parentCommentDto, savedReplyCommentDto,isLikedParentComment,command.userId()); | ||
| } else { | ||
| CommentQueryDto savedCommentDto = commentQueryPort.findRootCommentById(savedCommentId); | ||
| return commentQueryMapper.toRoot(savedCommentDto, false, command.userId()); | ||
| } | ||
|
hd0rable marked this conversation as resolved.
Comment on lines
+64
to
+76
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM |
||
|
|
||
| } | ||
|
|
||
| private Long createCommentDomain(CommentCreateCommand command) { | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.