From 1528b6c30ea65b66ba4c8b4ecefab105916202a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Wed, 20 May 2026 20:13:37 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20ShopNotificationService=20=ED=81=B4?= =?UTF-8?q?=EB=9E=98=EC=8A=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/ShopNotificationService.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/main/java/in/koreatech/koin/domain/notification/service/ShopNotificationService.java diff --git a/src/main/java/in/koreatech/koin/domain/notification/service/ShopNotificationService.java b/src/main/java/in/koreatech/koin/domain/notification/service/ShopNotificationService.java new file mode 100644 index 000000000..b00fc820f --- /dev/null +++ b/src/main/java/in/koreatech/koin/domain/notification/service/ShopNotificationService.java @@ -0,0 +1,40 @@ +package in.koreatech.koin.domain.notification.service; + +import static in.koreatech.koin.common.model.MobileAppPath.SHOP; +import static in.koreatech.koin.domain.notification.model.NotificationSubscribeType.SHOP_EVENT; + +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import in.koreatech.koin.domain.notification.model.Notification; +import in.koreatech.koin.domain.notification.model.NotificationFactory; +import in.koreatech.koin.domain.notification.repository.NotificationSubscribeRepository; +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +public class ShopNotificationService { + + private final NotificationService notificationService; + private final NotificationFactory notificationFactory; + private final NotificationSubscribeRepository notificationSubscribeRepository; + + public void sendShopEventCreateNotifications(Integer shopId, String shopName, String title, String thumbnailImage) { + List notifications = notificationSubscribeRepository + .findAllBySubscribeTypeAndDetailTypeIsNull(SHOP_EVENT) + .stream() + .filter(subscribe -> subscribe.getUser().getDeviceToken() != null) + .map(subscribe -> notificationFactory.generateShopEventCreateNotification( + SHOP, + shopId, + thumbnailImage, + shopName, + title, + subscribe.getUser() + )).toList(); + notificationService.pushNotifications(notifications); + } +} From c1793d1edd97903fe51154a33b930a7160ef45c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Wed, 20 May 2026 20:14:36 +0900 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20ShopEventListener=20onShopEventCreat?= =?UTF-8?q?e=20=EB=A9=94=EC=86=8C=EB=93=9C=20=EA=B0=84=EC=86=8C=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../eventlistener/ShopEventListener.java | 33 +++++-------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/src/main/java/in/koreatech/koin/domain/notification/eventlistener/ShopEventListener.java b/src/main/java/in/koreatech/koin/domain/notification/eventlistener/ShopEventListener.java index 0fcaf121f..fdd5fccb3 100644 --- a/src/main/java/in/koreatech/koin/domain/notification/eventlistener/ShopEventListener.java +++ b/src/main/java/in/koreatech/koin/domain/notification/eventlistener/ShopEventListener.java @@ -1,19 +1,11 @@ package in.koreatech.koin.domain.notification.eventlistener; -import static in.koreatech.koin.common.model.MobileAppPath.SHOP; -import static in.koreatech.koin.domain.notification.model.NotificationSubscribeType.SHOP_EVENT; - -import java.util.List; - import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; import org.springframework.transaction.event.TransactionalEventListener; import in.koreatech.koin.common.event.EventArticleCreateShopEvent; -import in.koreatech.koin.domain.notification.model.Notification; -import in.koreatech.koin.domain.notification.model.NotificationFactory; -import in.koreatech.koin.domain.notification.repository.NotificationSubscribeRepository; -import in.koreatech.koin.domain.notification.service.NotificationService; +import in.koreatech.koin.domain.notification.service.ShopNotificationService; import lombok.RequiredArgsConstructor; @Component @@ -21,24 +13,15 @@ @Profile("!test") public class ShopEventListener { // TODO : 리팩터링 필요 (비즈니스로직 제거 및 알림 책임만 갖도록) - private final NotificationService notificationService; - private final NotificationFactory notificationFactory; - private final NotificationSubscribeRepository notificationSubscribeRepository; + private final ShopNotificationService shopNotificationService; @TransactionalEventListener public void onShopEventCreate(EventArticleCreateShopEvent event) { - List notifications = notificationSubscribeRepository - .findAllBySubscribeTypeAndDetailTypeIsNull(SHOP_EVENT) - .stream() - .filter(subscribe -> subscribe.getUser().getDeviceToken() != null) - .map(subscribe -> notificationFactory.generateShopEventCreateNotification( - SHOP, - event.shopId(), - event.thumbnailImage(), - event.shopName(), - event.title(), - subscribe.getUser() - )).toList(); - notificationService.pushNotifications(notifications); + shopNotificationService.sendShopEventCreateNotifications( + event.shopId(), + event.shopName(), + event.title(), + event.thumbnailImage() + ); } } From 1f8d365e766aa264b13c31307c8c744bfcc7e339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Wed, 20 May 2026 20:14:56 +0900 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20TODO=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/notification/eventlistener/ShopEventListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/in/koreatech/koin/domain/notification/eventlistener/ShopEventListener.java b/src/main/java/in/koreatech/koin/domain/notification/eventlistener/ShopEventListener.java index fdd5fccb3..229b1c58b 100644 --- a/src/main/java/in/koreatech/koin/domain/notification/eventlistener/ShopEventListener.java +++ b/src/main/java/in/koreatech/koin/domain/notification/eventlistener/ShopEventListener.java @@ -11,7 +11,7 @@ @Component @RequiredArgsConstructor @Profile("!test") -public class ShopEventListener { // TODO : 리팩터링 필요 (비즈니스로직 제거 및 알림 책임만 갖도록) +public class ShopEventListener { private final ShopNotificationService shopNotificationService;