-
Notifications
You must be signed in to change notification settings - Fork 0
Feat: [FN-151] 카드셋 목록 조회시 즐겨찾기 수 정렬 기능 #47
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
3 commits
Select commit
Hold shift + click to select a range
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
18 changes: 17 additions & 1 deletion
18
src/main/java/project/flipnote/bookmark/entity/BookmarkTargetType.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,5 +1,21 @@ | ||
| package project.flipnote.bookmark.entity; | ||
|
|
||
| import lombok.extern.slf4j.Slf4j; | ||
| import project.flipnote.common.model.event.BookmarkEventTargetType; | ||
|
|
||
| @Slf4j | ||
| public enum BookmarkTargetType { | ||
| CARD_SET | ||
| CARD_SET; | ||
|
|
||
| public BookmarkEventTargetType toEventType() { | ||
| try { | ||
| return BookmarkEventTargetType.valueOf(this.name()); | ||
| } catch (IllegalArgumentException e) { | ||
| log.error("Failed to map BookmarkTargetType '{}' to BookmarkEventTargetType", this.name(), e); | ||
| throw new IllegalStateException( | ||
| "Invalid mapping from BookmarkTargetType to BookmarkEventTargetType: " + this.name(), | ||
| e | ||
| ); | ||
| } | ||
| } | ||
| } |
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
47 changes: 47 additions & 0 deletions
47
src/main/java/project/flipnote/cardset/listener/BulkCardSetBookmarkRemovedEventHandler.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,47 @@ | ||
| package project.flipnote.cardset.listener; | ||
|
|
||
| import org.springframework.dao.DataAccessException; | ||
| import org.springframework.retry.annotation.Backoff; | ||
| import org.springframework.retry.annotation.Recover; | ||
| import org.springframework.retry.annotation.Retryable; | ||
| import org.springframework.scheduling.annotation.Async; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.transaction.event.TransactionPhase; | ||
| import org.springframework.transaction.event.TransactionalEventListener; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import project.flipnote.cardset.service.CardSetService; | ||
| import project.flipnote.common.model.event.BookmarkEventTargetType; | ||
| import project.flipnote.common.model.event.BulkBookmarkRemovedEvent; | ||
|
|
||
| @Slf4j | ||
| @RequiredArgsConstructor | ||
| @Component | ||
| public class BulkCardSetBookmarkRemovedEventHandler { | ||
|
|
||
| private final CardSetService cardSetService; | ||
|
|
||
| @Async | ||
| @Retryable( | ||
| maxAttempts = 3, | ||
| retryFor = DataAccessException.class, | ||
| backoff = @Backoff(delay = 2000, multiplier = 2) | ||
| ) | ||
| @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) | ||
| public void handleBookmarkRemovedEvent(BulkBookmarkRemovedEvent event) { | ||
| if (event.targetType() != BookmarkEventTargetType.CARD_SET) { | ||
| return; | ||
| } | ||
|
|
||
| cardSetService.decrementBookmarkCount(event.targetIds()); | ||
| } | ||
|
|
||
| @Recover | ||
| public void recover(Exception ex, BulkBookmarkRemovedEvent event) { | ||
| log.error( | ||
| "카드셋 즐겨찾기 벌크 삭제 처리 중 예외 발생 : targetType={}, userId={}, targetIds={}", | ||
| event.targetType(), event.userId(), event.targetIds(), ex | ||
| ); | ||
| } | ||
| } |
47 changes: 47 additions & 0 deletions
47
src/main/java/project/flipnote/cardset/listener/CardSetBookmarkAddedEventHandler.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,47 @@ | ||
| package project.flipnote.cardset.listener; | ||
|
|
||
| import org.springframework.dao.DataAccessException; | ||
| import org.springframework.retry.annotation.Backoff; | ||
| import org.springframework.retry.annotation.Recover; | ||
| import org.springframework.retry.annotation.Retryable; | ||
| import org.springframework.scheduling.annotation.Async; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.transaction.event.TransactionPhase; | ||
| import org.springframework.transaction.event.TransactionalEventListener; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import project.flipnote.cardset.service.CardSetService; | ||
| import project.flipnote.common.model.event.BookmarkAddedEvent; | ||
| import project.flipnote.common.model.event.BookmarkEventTargetType; | ||
|
|
||
| @Slf4j | ||
| @RequiredArgsConstructor | ||
| @Component | ||
| public class CardSetBookmarkAddedEventHandler { | ||
|
|
||
| private final CardSetService cardSetService; | ||
|
|
||
| @Async | ||
| @Retryable( | ||
| maxAttempts = 3, | ||
| retryFor = DataAccessException.class, | ||
| backoff = @Backoff(delay = 2000, multiplier = 2) | ||
| ) | ||
| @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) | ||
| public void handleBookmarkAddedEvent(BookmarkAddedEvent event) { | ||
| if (event.targetType() != BookmarkEventTargetType.CARD_SET) { | ||
| return; | ||
| } | ||
|
|
||
| cardSetService.incrementBookmarkCount(event.targetId()); | ||
| } | ||
|
|
||
| @Recover | ||
| public void recover(Exception ex, BookmarkAddedEvent event) { | ||
| log.error( | ||
| "카드셋 즐겨찾기 추가 처리 중 예외 발생 : targetType={}, targetId={}, userId={}", | ||
| event.targetType(), event.targetId(), event.userId(), ex | ||
| ); | ||
| } | ||
| } |
47 changes: 47 additions & 0 deletions
47
src/main/java/project/flipnote/cardset/listener/CardSetBookmarkRemovedEventHandler.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,47 @@ | ||
| package project.flipnote.cardset.listener; | ||
|
|
||
| import org.springframework.dao.DataAccessException; | ||
| import org.springframework.retry.annotation.Backoff; | ||
| import org.springframework.retry.annotation.Recover; | ||
| import org.springframework.retry.annotation.Retryable; | ||
| import org.springframework.scheduling.annotation.Async; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.transaction.event.TransactionPhase; | ||
| import org.springframework.transaction.event.TransactionalEventListener; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import project.flipnote.cardset.service.CardSetService; | ||
| import project.flipnote.common.model.event.BookmarkEventTargetType; | ||
| import project.flipnote.common.model.event.BookmarkRemovedEvent; | ||
|
|
||
| @Slf4j | ||
| @RequiredArgsConstructor | ||
| @Component | ||
| public class CardSetBookmarkRemovedEventHandler { | ||
|
|
||
| private final CardSetService cardSetService; | ||
|
|
||
| @Async | ||
| @Retryable( | ||
| maxAttempts = 3, | ||
| retryFor = DataAccessException.class, | ||
| backoff = @Backoff(delay = 2000, multiplier = 2) | ||
| ) | ||
| @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) | ||
| public void handleBookmarkRemovedEvent(BookmarkRemovedEvent event) { | ||
| if (event.targetType() != BookmarkEventTargetType.CARD_SET) { | ||
| return; | ||
| } | ||
|
|
||
| cardSetService.decrementBookmarkCount(event.targetId()); | ||
| } | ||
|
|
||
| @Recover | ||
| public void recover(Exception ex, BookmarkRemovedEvent event) { | ||
| log.error( | ||
| "카드셋 즐겨찾기 삭제 처리 중 예외 발생 : targetType={}, targetId={}, userId={}", | ||
| event.targetType(), event.targetId(), event.userId(), ex | ||
| ); | ||
| } | ||
| } |
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.
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.
INNER JOIN으로 인한 결과 누락·total 불일치 가능성 — LEFT JOIN 권장
메타데이터가 없는 카드셋이 존재하면 BOOKMARK/LIKE 정렬 시 결과에서 누락되고(total는 전체 기준) 페이지네이션 불일치가 발생할 수 있습니다. LEFT JOIN으로 바꾸어 안전하게 정렬하세요.
보완 사항:
Also applies to: 79-81, 89-95
🤖 Prompt for AI Agents