Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into LF1-690-out-of-sto…
Browse files Browse the repository at this point in the history
…ck-notification
  • Loading branch information
nowgnas committed Dec 14, 2023
2 parents 8553da6 + 8ec7876 commit 6a394cd
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.List;
import kr.bb.notification.domain.notification.application.NotificationCommandService;
import kr.bb.notification.domain.notification.entity.NotificationCommand.NotificationInformation;
import kr.bb.notification.domain.notification.infrastructure.dto.OrderCancelNotification;
import kr.bb.notification.domain.notification.infrastructure.dto.OutOfStockNotification;
import kr.bb.notification.domain.notification.infrastructure.sms.SendSMS;
import kr.bb.notification.domain.notification.infrastructure.sse.SendSSE;
Expand Down Expand Up @@ -91,4 +92,15 @@ public void publishOutOfStockNotification(
outOfStockNotification.getPublishInformation(),
outOfStockNotification.getWhoToNotify().getStoreId());
}

public void publishOrderCancelNotification(
NotificationData<OrderCancelNotification> notification) {
NotificationInformation sseData =
NotificationInformation.getSSEData(
notification.getPublishInformation(), notification.getWhoToNotify().getStoreId());
sse.publishCustomer(sseData);

notificationCommandService.saveSingleNotification(
notification.getPublishInformation(), notification.getWhoToNotify().getStoreId());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package kr.bb.notification.domain.notification.infrastructure.dto;

import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
public class OrderCancelNotification {
private Long storeId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Map;
import kr.bb.notification.domain.notification.helper.NotificationActionHelper;
import kr.bb.notification.domain.notification.infrastructure.dto.OrderCancelNotification;
import kr.bb.notification.domain.notification.infrastructure.dto.OutOfStockNotification;
import lombok.RequiredArgsConstructor;
import org.springframework.cloud.aws.messaging.listener.Acknowledgment;
Expand Down Expand Up @@ -173,6 +174,23 @@ public void consumeOutOfStockNotificationQueue(
outOfStockNotification.getPublishInformation().setRole(Role.MANAGER);
// call facade
notificationFacadeHandler.publishOutOfStockNotification(outOfStockNotification);
}

@SqsListener(
value = "${cloud.aws.sqs.order-cancel-notification-queue.name}",
deletionPolicy = SqsMessageDeletionPolicy.NEVER)
public void consumeOrderCancelNotificationQueue(
@Payload String message, @Headers Map<String, String> headers, Acknowledgment ack)
throws JsonProcessingException {
NotificationData<OrderCancelNotification> orderCancelNotification =
objectMapper.readValue(
message,
objectMapper
.getTypeFactory()
.constructParametricType(NotificationData.class, OrderCancelNotification.class));
orderCancelNotification.getPublishInformation().setRole(Role.MANAGER);
// call facade
notificationFacadeHandler.publishOrderCancelNotification(orderCancelNotification);
ack.acknowledge();
}
}
3 changes: 3 additions & 0 deletions src/test/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,8 @@ cloud:
name: ""
url: ""
out-of-stock-notification-queue:
name: ""
url: ""
order-cancel-notification-queue:
name: ""
url: ""

0 comments on commit 6a394cd

Please sign in to comment.