-
Notifications
You must be signed in to change notification settings - Fork 0
[feat] 기록 삭제 api 개발 #178
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 개발 #178
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
5b0d76d
[feat] 관련 에러코드 추가 (#175)
hd0rable 25ba9ba
[feat] Record 삭제관련 도메인 코드 검증 추가 (#175)
hd0rable b229535
[feat] 기록 삭제 컨트롤러 작성 (#175)
hd0rable 3ef2cef
[feat] RecordCommandPersistenceAdapter.delete 작성 (#175)
hd0rable 59dcda0
[feat] RecordCommandPort.delete 작성 (#175)
hd0rable 084fd31
[feat] RecordDeleteCommand dto 작성 (#175)
hd0rable 83347f0
[feat] RecordDeleteResponse dto 작성 (#175)
hd0rable 1d37ddc
[feat] 기록삭제 유즈케이스 RecordDeleteUseCase 작성 (#175)
hd0rable 11b150e
[feat] 기록삭제 유즈케이스 구현체 RecordDeleteService 작성 (#175)
hd0rable daccf42
[feat] 테스트용 updateCommentCount 추가 (#175)
hd0rable 8fab215
[feat] RecordJpaRepository.findByPostIdAndStatus 작성 (#175)
hd0rable 322d9c3
[feat] 관련 에러코드 스웨거 추가 (#175)
hd0rable 74db07f
[feat] 기록 삭제 통합 테스트코드 작성 (#175)
hd0rable deac37e
[feat] 기록 삭제관련 record 단위도메인 테스트코드 추가 (#175)
hd0rable d5db07a
[remove] 더미 파일 삭제 (#175)
hd0rable 2437805
[test] 테스트 코드 수정 (#175)
hd0rable d5b677f
[refactor] Update/delete 쿼리 시 @Modifying(clearAutomatically = true, f…
hd0rable 60e9a0c
[test] 테스트 코드 수정 (#175)
hd0rable aba65e6
Merge remote-tracking branch 'origin/feat/#160-feed-delete' into feat…
hd0rable e854b84
[refactor] Update/delete 쿼리 시 @Modifying(clearAutomatically = true, f…
hd0rable a219ccd
[refactor] 기록 삭제 방 아이디 검증 캡슐화 (#175)
hd0rable d369a33
[refactor] 기록 삭제 소프트 딜리트 전략 수정 (#175)
hd0rable f4fe287
[chore] 피드 삭제 관련 주석 수정(#175)
hd0rable 2519adf
[test] 피드 삭제 테스트 코드 수정(#175)
hd0rable 53d8930
[test] 기록 삭제 테스트 코드 수정(#175)
hd0rable 72c85b7
[test] 기록 도메인 단위 테스트 코드 수정(#175)
hd0rable 0a80247
Merge branch 'develop' into feat/#175-record-delete
hd0rable 187a2e4
[teat] 테스트 코드 수정 (#160)
hd0rable 21f7a9d
Merge remote-tracking branch 'origin/develop' into feat/#175-record-d…
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
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
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
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/record/adapter/in/web/response/RecordDeleteResponse.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.record.adapter.in.web.response; | ||
|
|
||
| public record RecordDeleteResponse(Long roomId) { | ||
| public static RecordDeleteResponse of(Long roomId) { | ||
| return new RecordDeleteResponse(roomId); | ||
| } | ||
| } |
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
src/main/java/konkuk/thip/record/adapter/out/persistence/repository/RecordJpaRepository.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.record.adapter.out.persistence.repository; | ||
|
|
||
| import konkuk.thip.common.entity.StatusType; | ||
| import konkuk.thip.record.adapter.out.jpa.RecordJpaEntity; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| public interface RecordJpaRepository extends JpaRepository<RecordJpaEntity, Long>, RecordQueryRepository { | ||
| import java.util.Optional; | ||
|
|
||
| public interface RecordJpaRepository extends JpaRepository<RecordJpaEntity, Long>, RecordQueryRepository { | ||
| Optional<RecordJpaEntity> findByPostIdAndStatus(Long postId, StatusType status); | ||
| } |
7 changes: 7 additions & 0 deletions
7
src/main/java/konkuk/thip/record/application/port/in/RecordDeleteUseCase.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.record.application.port.in; | ||
|
|
||
| import konkuk.thip.record.application.port.in.dto.RecordDeleteCommand; | ||
|
|
||
| public interface RecordDeleteUseCase { | ||
| Long deleteRecord(RecordDeleteCommand command); | ||
| } |
9 changes: 0 additions & 9 deletions
9
src/main/java/konkuk/thip/record/application/port/in/dto/DummyQuery.java
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
src/main/java/konkuk/thip/record/application/port/in/dto/DummyResult.java
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
src/main/java/konkuk/thip/record/application/port/in/dto/RecordDeleteCommand.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,10 @@ | ||
| package konkuk.thip.record.application.port.in.dto; | ||
|
|
||
| public record RecordDeleteCommand( | ||
| Long roomId, | ||
|
|
||
| Long recordId, | ||
|
|
||
| Long userId | ||
| ) { | ||
| } | ||
hd0rable marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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
46 changes: 46 additions & 0 deletions
46
src/main/java/konkuk/thip/record/application/service/RecordDeleteService.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,46 @@ | ||
| package konkuk.thip.record.application.service; | ||
|
|
||
| import jakarta.transaction.Transactional; | ||
hd0rable marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import konkuk.thip.comment.application.port.out.CommentCommandPort; | ||
| import konkuk.thip.post.application.port.out.PostLikeCommandPort; | ||
| import konkuk.thip.record.application.port.in.RecordDeleteUseCase; | ||
| import konkuk.thip.record.application.port.in.dto.RecordDeleteCommand; | ||
| import konkuk.thip.record.application.port.out.RecordCommandPort; | ||
| import konkuk.thip.record.domain.Record; | ||
| import konkuk.thip.room.application.service.validator.RoomParticipantValidator; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class RecordDeleteService implements RecordDeleteUseCase { | ||
|
|
||
| private final RecordCommandPort recordCommandPort; | ||
| private final CommentCommandPort commentCommandPort; | ||
| private final PostLikeCommandPort postLikeCommandPort; | ||
|
|
||
| private final RoomParticipantValidator roomParticipantValidator; | ||
|
|
||
| @Override | ||
| @Transactional | ||
| public Long deleteRecord(RecordDeleteCommand command) { | ||
|
|
||
| // 1. 방 참여자 검증 | ||
| roomParticipantValidator.validateUserIsRoomMember(command.roomId(), command.userId()); | ||
|
|
||
| // 2. 기록 조회 및 검증 | ||
| Record record = recordCommandPort.getByIdOrThrow(command.recordId()); | ||
| // 2-1. 기록 삭제 권한 검증 | ||
| record.validateDeletable(command.userId(),command.roomId()); | ||
|
|
||
| // 3. 기록 삭제 | ||
| // 3-1. 기록 게시물 댓글 삭제 | ||
| commentCommandPort.softDeleteAllByPostId(command.recordId()); | ||
| // 3-2. 피드 게시물 좋아요 삭제 | ||
| postLikeCommandPort.deleteAllByPostId(command.recordId()); | ||
| // 3-3. 기록 삭제 | ||
| recordCommandPort.delete(record); | ||
|
|
||
hd0rable marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return command.roomId(); | ||
| } | ||
| } | ||
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.
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.
엇 이건 왜 추가하신거죠? (어떤 기능인지 몰라서,,ㅎ)
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.
#173 (comment)
앞 pr에서 코래가 친절하게 설명해주었습니다~ ㅎㅎ
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.
피드 삭제 에서 토끼가 말해준것처럼 jpa의 영속성의 1차 캐시를 비워주는 역할을합니다! 다른 트랜잭션에서 수행되는 메서드라편 필요없겠지만 UPATE,DELETE 쿼리를 날릴 시에 같은 여러 엔티티들을 한 트랜잭션에 처리하기 때문에 캐시 불일치로인한 오류를 막기 위해 추가했습니닷
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.
고수 LG™