diff --git a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/facade/package-info.java b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/facade/package-info.java new file mode 100644 index 0000000..b42d911 --- /dev/null +++ b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/facade/package-info.java @@ -0,0 +1,7 @@ +/** + * DDD Domain层和Infrastructure的粘合剂:通过倒置依赖. + * + *
domain层声明需要基础设施层实现的接口:RPC, DB, Cache, MQ等.
+ *为了方便产品人员查看领域层代码,梳理业务,统一放在facade package,减少对产品同学的干扰.
+ */ +package org.example.cp.oms.domain.facade; \ No newline at end of file diff --git a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/model/OrderMain.java b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/model/OrderMain.java index 4dd90e7..41052e0 100644 --- a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/model/OrderMain.java +++ b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/model/OrderMain.java @@ -4,6 +4,7 @@ import lombok.Setter; import lombok.extern.slf4j.Slf4j; import io.github.dddplus.api.RequestProfile; +import org.example.cp.oms.domain.model.vo.OrderItemDelegate; import org.example.cp.oms.spec.exception.OrderException; import org.example.cp.oms.domain.model.vo.ProductDelegate; import org.example.cp.oms.spec.model.IOrderMain; @@ -36,6 +37,7 @@ public class OrderMain implements IOrderMain { private String step; private ProductDelegate productDelegate; + private OrderItemDelegate orderItemDelegate; @Getter private String x1, x2; @@ -52,6 +54,7 @@ private OrderMain(OrderModelCreator creator) { this.requestProfile = creator.getRequestProfile(); this.productDelegate = ProductDelegate.createWith(creator); + this.orderItemDelegate = OrderItemDelegate.createWith(creator); } private OrderMain validate() throws OrderException { diff --git a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/model/vo/OrderItem.java b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/model/vo/OrderItem.java index f1270a4..bd9b5dd 100644 --- a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/model/vo/OrderItem.java +++ b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/model/vo/OrderItem.java @@ -2,5 +2,16 @@ import org.example.cp.oms.spec.model.vo.IOrderItem; +import java.math.BigDecimal; + +/** + * 订单项. + * + *每个{@link org.example.cp.oms.domain.model.OrderMain}包含多个订单项.
+ */ public class OrderItem implements IOrderItem { + private String sku; + private Integer quantity; + private String orderLine; + private BigDecimal price; } diff --git a/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/model/vo/OrderItemDelegate.java b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/model/vo/OrderItemDelegate.java new file mode 100644 index 0000000..919dde0 --- /dev/null +++ b/order-center-cp/cp-oc-domain/src/main/java/org/example/cp/oms/domain/model/vo/OrderItemDelegate.java @@ -0,0 +1,29 @@ +package org.example.cp.oms.domain.model.vo; + +import org.example.cp.oms.domain.model.OrderModelCreator; +import org.example.cp.oms.spec.model.vo.IOrderItem; +import org.example.cp.oms.spec.model.vo.IOrderItemDelegate; +import org.example.cp.oms.spec.model.vo.IProduct; +import org.example.cp.oms.spec.model.vo.IProductDelegate; + +import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.List; + +public class OrderItemDelegate implements IOrderItemDelegate { + + private List