Skip to content

Commit

Permalink
Merge pull request #68 from 28th-meetup/feat/sendFcm
Browse files Browse the repository at this point in the history
feat: fcm 메시지 전송
  • Loading branch information
summit45 authored Nov 21, 2023
2 parents b1ff60b + c1079ae commit a85b17c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/java/com/kusitms/jipbap/order/OrderService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -57,6 +60,12 @@ public OrderFoodResponse orderFood(String email, OrderFoodRequest dto) {
List<OrderDetail> 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);
}

Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit a85b17c

Please sign in to comment.