-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat] 댓글 삭제 api 개발 #134
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
[Feat] 댓글 삭제 api 개발 #134
Changes from all commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
1b26e36
[refactor] status 접근제어자 필드 수정 (#103)
hd0rable d921cb2
[refactor] status 접근제어자 필드 수정 (#103)
hd0rable e033c78
[feat] 댓글 삭제 관련 댓글 도메인 책임 메서드 추가 (#103)
hd0rable bf1d222
[feat] 댓글 삭제 컨트롤러 작성(#103)
hd0rable fe7a0e6
[feat] 댓글 조회 시 active한 댓글만 찾도록 수정(#103)
hd0rable bd6144f
[feat] decreaseCommentCount() 추가 (#103)
hd0rable 94be498
[feat] CommentDeleteUseCase 작성 (#103)
hd0rable 3b98312
[feat] CommentDeleteUseCase 구현체 CommentDeleteService 작성(#103)
hd0rable bb07074
[feat] updateFrom시에 상태 변경 추가(#103)
hd0rable 19d2ffa
[feat] findByCommentIdAndStatus 작성 (#103)
hd0rable c71bf52
[feat] CommentLikeCommandPersistenceAdapter.deleteAllByCommentId 추가 (…
hd0rable 5340f2a
[feat] CommentLikeCommandPort.deleteAllByCommentId 추가 (#103)
hd0rable 7ba26f3
[feat] CommentLikeJpaRepository .deleteAllByCommentId 추가 (#103)
hd0rable dc0784b
[fix] CommentLikeQueryPersistenceAdapter .isLikedCommentByUser 오류 수정 …
hd0rable 9c00a8e
[feat] 댓글 관련 에러 코드 추가 (#103)
hd0rable 5c52ef1
[feat] 피드 댓글 관련 함수 추가 (#103)
hd0rable 5bf535f
[feat] 피드 댓글 테스트 관련 함수 추가 (#103)
hd0rable f89a4f4
[feat] 기록 댓글 관련 함수 추가 (#103)
hd0rable dbac3eb
[feat] 댓글 삭제 관련 스웨거 문서 에러코드 추가 (#103)
hd0rable 9be50ed
[feat] 투표 댓글 관련 함수 추가 (#103)
hd0rable 71b471f
[test] 댓글 단위 테스트코드 수정 (#103)
hd0rable d443b2d
[test] 투표 단위 테스트코드 작성 (#103)
hd0rable 60859af
[test] 답글 생성 테스트 팩토리 메서드 추가 (#103)
hd0rable d5b0981
[test] 기록 단위 테스트코드 작성 (#103)
hd0rable 0d65540
[test] 피드 단위 도메인 테스트 코드 작성 (#103)
hd0rable c756b3c
[test] 댓글 삭제관련 댓글 단위 테스트코드 추가 (#103)
hd0rable 76c08bc
[test] 댓글 삭제 통합 테스트 코드 작성 (#103)
hd0rable c92b45d
[feat] PostQueryService.updatePost 추가 (#103)
hd0rable f4d54d0
[refactor] 피드 수정 관련 request dto 설명 추가 (#103)
hd0rable d9cdc8b
[refactor] 피드 수정 스웨거 관련 설명 추가 (#103)
hd0rable 27a609d
[refactor] 개발 환경 별로 다른 db반환값에 따른 분기처리 코드 추가 (#103)
hd0rable 96544bf
[refactor] 개발 환경 별로 다른 db반환값에 따른 분기처리 코드 추가 (#103)
hd0rable 7e3bdb8
[feat] PostQueryService.updatePost 추가 (#103)
hd0rable b7ccf95
[refactor] 안쓰는 의존성 삭제 (#103)
hd0rable 8ef7fbe
[refactor] status 접근 제어자 타입 수정 (#103)
hd0rable fc288ef
[refactor] 안쓰는 도메인 함수 삭제 (#103)
hd0rable 0305e48
[refactor] postId반환하도록 수정 (#103)
hd0rable 07e1dae
[feat] getId() 추가 (#103)
hd0rable d2412da
[feat] CommentDeleteResponse dto 작성(#103)
hd0rable 58cc5d5
[feat] CommentCommandPort.delete 작성 (#103)
hd0rable 116ec80
[feat] CommentCommandPersistenceAdapter.delete 구현 (#103)
hd0rable 318a5e7
[refactor] postId반환하도록 수정 (#103)
hd0rable ae2074f
[feat] Comment @SQLDelete 추가 (#103)
hd0rable 84320d6
[feat] CommentLikeJpaEntity에 cascade = CascadeType.ALL 속성 추가 (#103)
hd0rable cb298d1
[refactor] 네이티브 쿼리 jpql로 수정 (#103)
hd0rable eed90c7
[refactor] 네이티브 쿼리 jpql로 수정 (#103)
hd0rable 2896725
[rename] 헬퍼서비스 이름 변경 및 어노테이션 변경 (#103)
hd0rable 7fcdb6b
[refactor] 안쓰는 에러코드 수정 (#103)
hd0rable b6af8ae
[refactor] 안쓰는 에러코드 수정 (#103)
hd0rable 2d8ed70
[test] 테스트 코드 수정 (#103)
hd0rable 4f50afe
[refactor] 댓글 좋아요 삭제 먼저 후 댓글 삭제 (#103)
hd0rable a59f1d1
[test] 테스트 코드 수정 (#103)
hd0rable ad84e71
Merge remote-tracking branch 'origin/develop' into feat/#103-comment-…
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
7 changes: 7 additions & 0 deletions
7
src/main/java/konkuk/thip/comment/adapter/in/web/response/CommentDeleteResponse.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,7 @@ | ||
| package konkuk.thip.comment.adapter.in.web.response; | ||
|
|
||
| public record CommentDeleteResponse(Long postId) { | ||
| public static CommentDeleteResponse of(Long postId) { | ||
| return new CommentDeleteResponse(postId); | ||
| } | ||
| } |
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
5 changes: 4 additions & 1 deletion
5
...ain/java/konkuk/thip/comment/adapter/out/persistence/repository/CommentJpaRepository.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,8 +1,11 @@ | ||
| package konkuk.thip.comment.adapter.out.persistence.repository; | ||
|
|
||
| import konkuk.thip.comment.adapter.out.jpa.CommentJpaEntity; | ||
| import konkuk.thip.common.entity.StatusType; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| public interface CommentJpaRepository extends JpaRepository<CommentJpaEntity, Long> { | ||
| int countByPostJpaEntity_PostId(Long postId); | ||
| Optional<CommentJpaEntity> findByCommentIdAndStatus(Long commentId, StatusType status); | ||
| } |
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
6 changes: 6 additions & 0 deletions
6
src/main/java/konkuk/thip/comment/application/port/in/CommentDeleteUseCase.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,6 @@ | ||
| package konkuk.thip.comment.application.port.in; | ||
|
|
||
|
|
||
| public interface CommentDeleteUseCase { | ||
| Long deleteComment(Long commentId, Long userId); | ||
| } |
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 |
|---|---|---|
|
|
@@ -21,4 +21,6 @@ default Comment getByIdOrThrow(Long id) { | |
|
|
||
| void update(Comment comment); | ||
|
|
||
| void delete(Comment comment); | ||
|
|
||
| } | ||
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
53 changes: 53 additions & 0 deletions
53
src/main/java/konkuk/thip/comment/application/service/CommentDeleteService.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,53 @@ | ||
| package konkuk.thip.comment.application.service; | ||
|
|
||
| import jakarta.transaction.Transactional; | ||
| import konkuk.thip.comment.application.port.in.CommentDeleteUseCase; | ||
| import konkuk.thip.comment.application.port.out.CommentCommandPort; | ||
| import konkuk.thip.comment.application.port.out.CommentLikeCommandPort; | ||
| import konkuk.thip.comment.application.service.validator.CommentAuthorizationValidator; | ||
| import konkuk.thip.comment.domain.Comment; | ||
| import konkuk.thip.common.post.CommentCountUpdatable; | ||
| import konkuk.thip.common.post.service.PostHandler; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class CommentDeleteService implements CommentDeleteUseCase { | ||
|
|
||
| private final CommentCommandPort commentCommandPort; | ||
| private final CommentLikeCommandPort commentLikeCommandPort; | ||
|
|
||
| private final PostHandler postHandler; | ||
| private final CommentAuthorizationValidator commentAuthorizationValidator; | ||
|
|
||
| @Override | ||
| @Transactional | ||
| public Long deleteComment(Long commentId, Long userId) { | ||
|
|
||
| // 1. 댓글 조회 및 권한 검증 | ||
| Comment comment = commentCommandPort.getByIdOrThrow(commentId); | ||
| // 1-1. 게시글 타입에 따른 댓글 삭제 권한 검증 | ||
| CommentCountUpdatable post = postHandler.findPost(comment.getPostType(), comment.getTargetPostId()); | ||
| commentAuthorizationValidator.validateUserCanAccessPostForComment(comment.getPostType(), post, userId); | ||
|
|
||
| // 2. 댓글 삭제 권한 검증 및 소프트 딜리트 | ||
| comment.validateDeletable(userId); | ||
| // 2-1. 댓글 좋아요 삭제 | ||
| commentLikeCommandPort.deleteAllByCommentId(commentId); | ||
|
|
||
| // 3. 댓글 삭제 | ||
| commentCommandPort.delete(comment); | ||
|
|
||
| //TODO 게시물의 댓글 수 증가/감소 동시성 제어 로직 추가해야됨 | ||
|
hd0rable marked this conversation as resolved.
Collaborator
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. 이거까지 고려해도 좋지요~~ |
||
|
|
||
| // 4. 게시글 댓글 수 감소 | ||
| // 4-1. 도메인 게시물 댓글 수 감소 | ||
| post.decreaseCommentCount(); | ||
| // 4-2 Jpa엔티티 게시물 댓글 수 감소 | ||
| postHandler.updatePost(comment.getPostType(), post); | ||
|
|
||
| return post.getId(); | ||
| } | ||
|
|
||
| } | ||
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
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.
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.