-
Notifications
You must be signed in to change notification settings - Fork 2
refactor: 키워드 알림 EventListener 책임 분리 #2237
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
Open
Soundbar91
wants to merge
26
commits into
develop
Choose a base branch
from
refactor/2219-article-keyword-event-listener
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
5ccdfac
feat: 분실물 게시글 키워드 알림 이벤트 클래스 추가
Soundbar91 c9264c6
feat: 분실물 게시글 키워드 알림 이벤트 리스너 추가
Soundbar91 196f0f6
feat: 분실물 게시글 키워드 추출 클래스 추가
Soundbar91 0914c09
fix: ArticleKeywordEvent 시그니처 수정
Soundbar91 fd783ba
fix: 키워드 알림, 분실물 키워드 알림 생성 로직 분리
Soundbar91 bbf9c26
fix: ArticleKeywordEventListene 미사용 로직 삭제
Soundbar91 48c3e62
fix: ArticleKeywordEventListene 미사용 로직 삭제
Soundbar91 c559974
feat: LostItemKeywordEventListener 추가
Soundbar91 cf5a468
fix: 이벤트 키워드 알림 payload 변경
Soundbar91 e1391cd
refactor: 키워드 매칭 사용자 조회 책임 이동
Soundbar91 0b18752
refactor: 키워드 알림 발송 책임 서비스로 이동
Soundbar91 5684531
refactor: 키워드 이벤트 리스너 위임만 수행
Soundbar91 ea084bf
fix: 방어로직 삭제
Soundbar91 3b742a1
fix: 게시글 중복처리 로직 수정
Soundbar91 513a60b
fix: KoreatechArticleKeywordEvent 수정
Soundbar91 297644d
refactor: 키워드 매칭 사용자 선정 로직 정리
Soundbar91 5a6e43c
refactor: 키워드 알림 서비스 로직 정리
Soundbar91 572c9b6
refactor: 분실물 키워드 알림 책임 분리
Soundbar91 31267b1
refactor: 키워드 추출기 통합
Soundbar91 3b35510
refactor: 키워드 사용자 매칭 로직 분리
Soundbar91 71f2990
test: 잘못된 키워드 알림 테스트 제거
Soundbar91 2319bdf
refactor: 미사용 키워드 메서드 제거
Soundbar91 52f9ede
refactor: 미사용 키워드 필드 제거
Soundbar91 ec1927f
fix: 미사용 메소드 삭제
Soundbar91 9dddac7
feat: Profile 추가
Soundbar91 9179ca1
fix: keyword 하드 코딩 수정
Soundbar91 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
19 changes: 0 additions & 19 deletions
19
src/main/java/in/koreatech/koin/common/event/ArticleKeywordEvent.java
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
src/main/java/in/koreatech/koin/common/event/KoreatechArticleKeywordEvent.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,31 @@ | ||
| package in.koreatech.koin.common.event; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| public record KoreatechArticleKeywordEvent( | ||
| Integer articleId, | ||
| Integer boardId, | ||
| String articleTitle, | ||
| MatchedKeywordUsers matchedKeywordUsers | ||
| ) { | ||
| public record MatchedKeywordUsers( | ||
| Map<String, List<Integer>> userIdsByKeyword | ||
| ) { | ||
|
|
||
| } | ||
|
|
||
| public static KoreatechArticleKeywordEvent of( | ||
| Integer articleId, | ||
| Integer boardId, | ||
| String articleTitle, | ||
| Map<String, List<Integer>> userIdsByKeyword | ||
| ) { | ||
| return new KoreatechArticleKeywordEvent( | ||
| articleId, | ||
| boardId, | ||
| articleTitle, | ||
| new MatchedKeywordUsers(userIdsByKeyword) | ||
| ); | ||
| } | ||
|
Comment on lines
+18
to
+30
|
||
| } | ||
31 changes: 31 additions & 0 deletions
31
src/main/java/in/koreatech/koin/common/event/LostItemKeywordEvent.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,31 @@ | ||
| package in.koreatech.koin.common.event; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| public record LostItemKeywordEvent( | ||
| Integer articleId, | ||
| String articleTitle, | ||
| Integer authorId, | ||
| MatchedKeywordUsers matchedKeywordUsers | ||
| ) { | ||
| public record MatchedKeywordUsers( | ||
| Map<String, List<Integer>> userIdsByKeyword | ||
| ) { | ||
|
|
||
| } | ||
|
|
||
| public static LostItemKeywordEvent of( | ||
| Integer articleId, | ||
| String articleTitle, | ||
| Integer authorId, | ||
| Map<String, List<Integer>> userIdsByKeyword | ||
| ) { | ||
| return new LostItemKeywordEvent( | ||
| articleId, | ||
| articleTitle, | ||
| authorId, | ||
| new MatchedKeywordUsers(userIdsByKeyword) | ||
| ); | ||
| } | ||
|
Comment on lines
+18
to
+30
|
||
| } | ||
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
50 changes: 50 additions & 0 deletions
50
...in/java/in/koreatech/koin/domain/community/keyword/service/ArticleKeywordUserMatcher.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,50 @@ | ||
| package in.koreatech.koin.domain.community.keyword.service; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.LinkedHashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import in.koreatech.koin.domain.community.keyword.enums.KeywordCategory; | ||
| import in.koreatech.koin.domain.community.keyword.model.ArticleKeyword; | ||
| import in.koreatech.koin.domain.community.keyword.model.ArticleKeywordUserMap; | ||
| import in.koreatech.koin.domain.community.keyword.repository.ArticleKeywordUserMapRepository; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| @Transactional(readOnly = true) | ||
| public class ArticleKeywordUserMatcher { | ||
|
|
||
| private final ArticleKeywordUserMapRepository articleKeywordUserMapRepository; | ||
|
|
||
| public Map<String, List<Integer>> findUserIdsByMatchedKeyword( | ||
| KeywordCategory category, | ||
| List<String> matchedKeywords | ||
| ) { | ||
| Map<Integer, ArticleKeyword> keywordByUserId = new LinkedHashMap<>(); | ||
| List<ArticleKeywordUserMap> keywordUserMaps = articleKeywordUserMapRepository | ||
| .findAllByArticleKeywordCategoryAndArticleKeywordKeywordIn(category, matchedKeywords); | ||
|
|
||
| for (ArticleKeywordUserMap keywordUserMap : keywordUserMaps) { | ||
| Integer userId = keywordUserMap.getUser().getId(); | ||
| ArticleKeyword keyword = keywordUserMap.getArticleKeyword(); | ||
| ArticleKeyword previousKeyword = keywordByUserId.get(userId); | ||
|
|
||
| if (keyword.hasLongerKeywordThan(previousKeyword)) { | ||
| keywordByUserId.put(userId, keyword); | ||
| } | ||
| } | ||
|
|
||
| Map<String, List<Integer>> userIdsByKeyword = new LinkedHashMap<>(); | ||
| for (Map.Entry<Integer, ArticleKeyword> entry : keywordByUserId.entrySet()) { | ||
| Integer userId = entry.getKey(); | ||
| String keyword = entry.getValue().getKeyword(); | ||
| userIdsByKeyword.computeIfAbsent(keyword, ignored -> new ArrayList<>()).add(userId); | ||
| } | ||
| return userIdsByKeyword; | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.