From fef13191038619850f2f32e89fb1e7302b87d91b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Mon, 30 Mar 2026 04:53:36 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20updateNotification=20=EC=9E=90?= =?UTF-8?q?=EB=A3=8C=ED=98=95=20Set=EC=9C=BC=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../article/repository/ArticleRepository.java | 3 ++- .../keyword/dto/KeywordNotificationRequest.java | 6 +++--- .../community/keyword/service/KeywordService.java | 10 +++------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/main/java/in/koreatech/koin/domain/community/article/repository/ArticleRepository.java b/src/main/java/in/koreatech/koin/domain/community/article/repository/ArticleRepository.java index daabf61dc3..f0e6f40551 100644 --- a/src/main/java/in/koreatech/koin/domain/community/article/repository/ArticleRepository.java +++ b/src/main/java/in/koreatech/koin/domain/community/article/repository/ArticleRepository.java @@ -4,6 +4,7 @@ import static in.koreatech.koin.domain.community.article.service.ArticleService.NOTICE_BOARD_ID; import java.time.LocalDate; +import java.util.Collection; import java.util.List; import java.util.Optional; @@ -28,7 +29,7 @@ public interface ArticleRepository extends Repository { Optional
findById(Integer articleId); - List
findAllByIdIn(List articleIds); + List
findAllByIdIn(Collection articleIds); Page
findAll(Pageable pageable); diff --git a/src/main/java/in/koreatech/koin/domain/community/keyword/dto/KeywordNotificationRequest.java b/src/main/java/in/koreatech/koin/domain/community/keyword/dto/KeywordNotificationRequest.java index 627c9c0026..f140a9ccc4 100644 --- a/src/main/java/in/koreatech/koin/domain/community/keyword/dto/KeywordNotificationRequest.java +++ b/src/main/java/in/koreatech/koin/domain/community/keyword/dto/KeywordNotificationRequest.java @@ -1,6 +1,6 @@ package in.koreatech.koin.domain.community.keyword.dto; -import java.util.List; +import java.util.Set; import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy; import com.fasterxml.jackson.databind.annotation.JsonNaming; @@ -9,10 +9,10 @@ import jakarta.validation.constraints.NotNull; @JsonNaming(SnakeCaseStrategy.class) -public record KeywordNotificationRequest ( +public record KeywordNotificationRequest( @Schema(description = "업데이트 된 공지사항 목록", example = "[1, 2, 3]") @NotNull - List updateNotification + Set updateNotification ) { } diff --git a/src/main/java/in/koreatech/koin/domain/community/keyword/service/KeywordService.java b/src/main/java/in/koreatech/koin/domain/community/keyword/service/KeywordService.java index b8e79e4759..8dd92cd4a9 100644 --- a/src/main/java/in/koreatech/koin/domain/community/keyword/service/KeywordService.java +++ b/src/main/java/in/koreatech/koin/domain/community/keyword/service/KeywordService.java @@ -147,18 +147,14 @@ public ArticleKeywordsSuggestionResponse suggestKeywords() { } public void sendKeywordNotification(KeywordNotificationRequest request) { - List updateNotificationIds = request.updateNotification().stream() - .distinct() - .toList(); - - if (updateNotificationIds.isEmpty()) { + if (request.updateNotification().isEmpty()) { return; } - List
fetchedArticles = articleRepository.findAllByIdIn(updateNotificationIds); + List
fetchedArticles = articleRepository.findAllByIdIn(request.updateNotification()); var articleById = fetchedArticles.stream() .collect(Collectors.toMap(Article::getId, article -> article)); - List
articles = updateNotificationIds.stream() + List
articles = request.updateNotification().stream() .map(articleId -> { Article article = articleById.get(articleId); if (article == null) { From 15b41e760d13a33ab2b320ebef441bbb9435255f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Mon, 30 Mar 2026 04:58:46 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C?= =?UTF-8?q?=20=EA=B2=80=EC=A6=9D=20=EB=A1=9C=EC=A7=81=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../keyword/service/KeywordService.java | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/main/java/in/koreatech/koin/domain/community/keyword/service/KeywordService.java b/src/main/java/in/koreatech/koin/domain/community/keyword/service/KeywordService.java index 8dd92cd4a9..5443125746 100644 --- a/src/main/java/in/koreatech/koin/domain/community/keyword/service/KeywordService.java +++ b/src/main/java/in/koreatech/koin/domain/community/keyword/service/KeywordService.java @@ -11,7 +11,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import in.koreatech.koin.domain.community.article.exception.ArticleNotFoundException; +import in.koreatech.koin.common.event.ArticleKeywordEvent; import in.koreatech.koin.domain.community.article.dto.ArticleKeywordResult; import in.koreatech.koin.domain.community.article.model.Article; import in.koreatech.koin.domain.community.article.repository.ArticleRepository; @@ -23,7 +23,6 @@ import in.koreatech.koin.domain.community.keyword.exception.KeywordDuplicationException; import in.koreatech.koin.domain.community.keyword.exception.KeywordLimitExceededException; import in.koreatech.koin.domain.community.keyword.model.ArticleKeyword; -import in.koreatech.koin.common.event.ArticleKeywordEvent; import in.koreatech.koin.domain.community.keyword.model.ArticleKeywordSuggestCache; import in.koreatech.koin.domain.community.keyword.model.ArticleKeywordUserMap; import in.koreatech.koin.domain.community.keyword.repository.ArticleKeywordRepository; @@ -151,19 +150,7 @@ public void sendKeywordNotification(KeywordNotificationRequest request) { return; } - List
fetchedArticles = articleRepository.findAllByIdIn(request.updateNotification()); - var articleById = fetchedArticles.stream() - .collect(Collectors.toMap(Article::getId, article -> article)); - List
articles = request.updateNotification().stream() - .map(articleId -> { - Article article = articleById.get(articleId); - if (article == null) { - throw ArticleNotFoundException.withDetail("articleId: " + articleId); - } - return article; - }) - .toList(); - + List
articles = articleRepository.findAllByIdIn(request.updateNotification()); List keywordEvents = keywordExtractor.matchKeyword(articles, null); for (ArticleKeywordEvent event : keywordEvents) { eventPublisher.publishEvent(event);