|
11 | 11 | import org.springframework.stereotype.Service; |
12 | 12 | import org.springframework.transaction.annotation.Transactional; |
13 | 13 |
|
14 | | -import in.koreatech.koin.domain.community.article.exception.ArticleNotFoundException; |
| 14 | +import in.koreatech.koin.common.event.ArticleKeywordEvent; |
15 | 15 | import in.koreatech.koin.domain.community.article.dto.ArticleKeywordResult; |
16 | 16 | import in.koreatech.koin.domain.community.article.model.Article; |
17 | 17 | import in.koreatech.koin.domain.community.article.repository.ArticleRepository; |
|
23 | 23 | import in.koreatech.koin.domain.community.keyword.exception.KeywordDuplicationException; |
24 | 24 | import in.koreatech.koin.domain.community.keyword.exception.KeywordLimitExceededException; |
25 | 25 | import in.koreatech.koin.domain.community.keyword.model.ArticleKeyword; |
26 | | -import in.koreatech.koin.common.event.ArticleKeywordEvent; |
27 | 26 | import in.koreatech.koin.domain.community.keyword.model.ArticleKeywordSuggestCache; |
28 | 27 | import in.koreatech.koin.domain.community.keyword.model.ArticleKeywordUserMap; |
29 | 28 | import in.koreatech.koin.domain.community.keyword.repository.ArticleKeywordRepository; |
@@ -151,19 +150,7 @@ public void sendKeywordNotification(KeywordNotificationRequest request) { |
151 | 150 | return; |
152 | 151 | } |
153 | 152 |
|
154 | | - List<Article> fetchedArticles = articleRepository.findAllByIdIn(request.updateNotification()); |
155 | | - var articleById = fetchedArticles.stream() |
156 | | - .collect(Collectors.toMap(Article::getId, article -> article)); |
157 | | - List<Article> articles = request.updateNotification().stream() |
158 | | - .map(articleId -> { |
159 | | - Article article = articleById.get(articleId); |
160 | | - if (article == null) { |
161 | | - throw ArticleNotFoundException.withDetail("articleId: " + articleId); |
162 | | - } |
163 | | - return article; |
164 | | - }) |
165 | | - .toList(); |
166 | | - |
| 153 | + List<Article> articles = articleRepository.findAllByIdIn(request.updateNotification()); |
167 | 154 | List<ArticleKeywordEvent> keywordEvents = keywordExtractor.matchKeyword(articles, null); |
168 | 155 | for (ArticleKeywordEvent event : keywordEvents) { |
169 | 156 | eventPublisher.publishEvent(event); |
|
0 commit comments