-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from nowgnas/LF1-674-new-order-notification
✨ LF1-674 신규 주문 알림 sse
- Loading branch information
Showing
11 changed files
with
161 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
.../java/kr/bb/notification/domain/notification/infrastructure/dto/NewOrderNotification.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package kr.bb.notification.domain.notification.infrastructure.dto; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Builder | ||
public class NewOrderNotification { | ||
private String productName; | ||
private Long storeId; | ||
private OrderType orderType; | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/kr/bb/notification/domain/notification/infrastructure/dto/OrderType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package kr.bb.notification.domain.notification.infrastructure.dto; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public enum OrderType { | ||
PICKUP("픽업"), | ||
SUBSCRIBE("구독"), | ||
DELIVERY("배송"); | ||
private final String orderType; | ||
|
||
OrderType(String orderType) { | ||
this.orderType = orderType; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...in/java/kr/bb/notification/domain/notification/infrastructure/message/SQSPublishTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package kr.bb.notification.domain.notification.infrastructure.message; | ||
|
||
import bloomingblooms.domain.notification.NotificationData; | ||
import bloomingblooms.domain.notification.NotificationKind; | ||
import bloomingblooms.domain.notification.PublishNotificationInformation; | ||
import com.amazonaws.services.sqs.AmazonSQS; | ||
import com.amazonaws.services.sqs.model.SendMessageRequest; | ||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import kr.bb.notification.domain.notification.infrastructure.dto.NewOrderNotification; | ||
import kr.bb.notification.domain.notification.infrastructure.dto.OrderType; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class SQSPublishTest { | ||
private final AmazonSQS sqs; | ||
private final ObjectMapper objectMapper; | ||
|
||
@Value("${cloud.aws.sqs.new-order-queue.url}") | ||
private String newOrder; | ||
|
||
public void sqsSend() throws JsonProcessingException { | ||
NewOrderNotification build = | ||
NewOrderNotification.builder() | ||
.orderType(OrderType.SUBSCRIBE) | ||
.productName("장미 꽃다발") | ||
.storeId(1L) | ||
.build(); | ||
|
||
SendMessageRequest sendMessageRequest = | ||
new SendMessageRequest( | ||
newOrder, | ||
objectMapper.writeValueAsString( | ||
NotificationData.builder() | ||
.whoToNotify(build) | ||
.publishInformation( | ||
PublishNotificationInformation.builder() | ||
.message(build.getProductName() + " 상품이 주문되었습니다") | ||
.notificationUrl("/orders/" + build.getStoreId()) | ||
.notificationKind(NotificationKind.NEW_ORDER) | ||
.build()) | ||
.build())); | ||
sqs.sendMessage(sendMessageRequest); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,3 +46,6 @@ cloud: | |
question-register-notification-queue: | ||
name: "" | ||
url: "" | ||
new-order-queue: | ||
name: "" | ||
url: "" |