주문시 checkStock 를 체크하도록 변경함

This commit is contained in:
kimscott
2019-09-27 14:16:23 +09:00
parent fffc3e0f8a
commit 2eb86b2fe2
2 changed files with 15 additions and 9 deletions

View File

@@ -46,6 +46,7 @@ public class Order {
throw new RuntimeException(); throw new RuntimeException();
} }
if("true".equalsIgnoreCase(env.getProperty("checkStock"))){
// 1. 주문에 대한 상품 조회 - API // 1. 주문에 대한 상품 조회 - API
String productUrl = env.getProperty("productUrl") + "/products/" + productId; String productUrl = env.getProperty("productUrl") + "/products/" + productId;
@@ -59,6 +60,7 @@ public class Order {
if( jsonObject.get("stock").getAsInt() < getQuantity()){ if( jsonObject.get("stock").getAsInt() < getQuantity()){
throw new RuntimeException("No Available stock!"); throw new RuntimeException("No Available stock!");
} }
}
OrderPlaced orderPlaced = new OrderPlaced(); OrderPlaced orderPlaced = new OrderPlaced();
try { try {

View File

@@ -3,6 +3,10 @@ server:
eventTopic: eventTopic eventTopic: eventTopic
## 주문은 product 정보가 필요하다.
## checkStock 를 true 로 준다면, product 서비스가 죽어있을때는 주문이 안된다.
checkStock: false
--- ---
spring: spring:
profiles: default profiles: default