论聚合持久化

如果无法正常显示,请先停止浏览器的去广告插件。
分享至:
1. 梅雪松
2. 持久化在 分层架构中的演进 经典三层架构 DDD分层架构 ⽤户界⾯层 ⽤户界⾯层 业务逻辑层 应⽤层 数据访问层 数据库 领域层 基础设施层
3. (Aggregate) 以聚合为单元 进⾏持久化 (Root) ⼀个典型的资源库(Repository)接⼝定义 ( Boundary) Eric Evans public interface OrderRepository { public Order findById(String id); public void save(Order order); public void remove(Order order); }
4. 问题⼀
5. 问题⼆ NoSQL
6. Aggregate- Persistence 回归问题本源 Service Repository findById Order Order Order order.pay() save Order Order
7. Aggregate- Persistence 回归问题本源 Service Repository findById Aggregate<T> Aggregate<T> Order Order Snapshot Snapshot Order order.pay() save Aggregate<T> Aggregate<T> Order Order Snapshot Snapshot
8. Aggregate- Persistence 示例代码 public interface OrderRepository { Aggregate<Order> findById(String orderId); void save(Aggregate<Order> orderAggregate); void remove(Aggregate<Order> orderAggregate); } public class OrderService { public void checkout(String orderId, CheckoutRequest request) { Aggregate<Order> aggregate = orderRepository.findById(orderId); Order order = aggregate.getRoot(); Payment payment = new Payment(request.getAmount()); order.checkout(payment); orderRepository.save(aggregate); } }
9. Aggregate- Persistence / Version Aggregate<T> Order OrderItem
10. THANK YOU

trang chủ - Wiki
Copyright © 2011-2024 iteam. Current version is 2.137.3. UTC+08:00, 2024-11-28 19:44
浙ICP备14020137号-1 $bản đồ khách truy cập$