From c1079ae8e7261b22eadd634b027a22fee8f2fa70 Mon Sep 17 00:00:00 2001 From: summit45 Date: Tue, 21 Nov 2023 22:42:59 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20fcm=20=EB=A9=94=EC=8B=9C=EC=A7=80=20?= =?UTF-8?q?=EC=A0=84=EC=86=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/kusitms/jipbap/order/OrderService.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/kusitms/jipbap/order/OrderService.java b/src/main/java/com/kusitms/jipbap/order/OrderService.java index 03e7f3b..4ee7f08 100644 --- a/src/main/java/com/kusitms/jipbap/order/OrderService.java +++ b/src/main/java/com/kusitms/jipbap/order/OrderService.java @@ -6,6 +6,8 @@ import com.kusitms.jipbap.food.FoodRepository; import com.kusitms.jipbap.food.exception.FoodNotExistsException; import com.kusitms.jipbap.food.exception.FoodOptionNotExistsException; +import com.kusitms.jipbap.notification.FCMNotificationService; +import com.kusitms.jipbap.notification.FCMRequestDto; import com.kusitms.jipbap.order.dto.*; import com.kusitms.jipbap.order.exception.*; import com.kusitms.jipbap.store.Store; @@ -34,6 +36,7 @@ public class OrderService { private final FoodRepository foodRepository; private final FoodOptionRepository foodOptionRepository; private final StoreRepository storeRepository; + private final FCMNotificationService fcmNotificationService; @Transactional public OrderFoodResponse orderFood(String email, OrderFoodRequest dto) { @@ -57,6 +60,12 @@ public OrderFoodResponse orderFood(String email, OrderFoodRequest dto) { List orderedFoodList = saveOrderFoodDetail(order.getId(), dto.getOrderFoodDetailList()); order.setOrderDetail(orderedFoodList); + // 알림 등 로직 추가 가능 + FCMRequestDto fcmRequestDto = new FCMRequestDto(store.getOwner().getId(), "주문이 들어왔습니다", "주문을 확인해주세요."); + String ans = fcmNotificationService.sendNotificationByToken(fcmRequestDto); + log.info(ans); + orderRepository.save(order); + return new OrderFoodResponse(order); } @@ -128,8 +137,11 @@ public void processOrder(String email, Long orderId, String status) { throw new OrderStatusAlreadyExistsException("이미 해당 주문 상태입니다."); } order.setStatus(newStatus); // 주문 상태 변경 - // 알림 등 로직 추가 가능 + // 알림 등 로직 추가 가능 + FCMRequestDto dto = new FCMRequestDto(seller.getId(), "주문이 들어왔습니다", "주문을 확인해주세요."); + String ans = fcmNotificationService.sendNotificationByToken(dto); + log.info(ans); orderRepository.save(order); }