25
25
26
26
import static java .util .stream .Collectors .toList ;
27
27
28
- @ Transactional
29
28
public class OrderService {
30
29
31
30
private Logger logger = LoggerFactory .getLogger (getClass ());
@@ -66,6 +65,7 @@ public OrderService(SagaInstanceFactory sagaInstanceFactory,
66
65
this .meterRegistry = meterRegistry ;
67
66
}
68
67
68
+ @ Transactional
69
69
public Order createOrder (long consumerId , long restaurantId , DeliveryInformation deliveryInformation ,
70
70
List <MenuItemIdAndQuantity > lineItems ) {
71
71
Restaurant restaurant = restaurantRepository .findById (restaurantId )
@@ -112,6 +112,7 @@ public void noteReversingAuthorization(Long orderId) {
112
112
throw new UnsupportedOperationException ();
113
113
}
114
114
115
+ @ Transactional
115
116
public Order cancel (Long orderId ) {
116
117
Order order = orderRepository .findById (orderId )
117
118
.orElseThrow (() -> new OrderNotFoundException (orderId ));
@@ -149,6 +150,7 @@ public void confirmCancelled(long orderId) {
149
150
updateOrder (orderId , Order ::noteCancelled );
150
151
}
151
152
153
+ @ Transactional
152
154
public Order reviseOrder (long orderId , OrderRevision orderRevision ) {
153
155
Order order = orderRepository .findById (orderId ).orElseThrow (() -> new OrderNotFoundException (orderId ));
154
156
ReviseOrderSagaData sagaData = new ReviseOrderSagaData (order .getConsumerId (), orderId , null , orderRevision );
@@ -172,13 +174,11 @@ public void confirmRevision(long orderId, OrderRevision revision) {
172
174
updateOrder (orderId , order -> order .confirmRevision (revision ));
173
175
}
174
176
175
- @ Transactional (propagation = Propagation .MANDATORY )
176
177
public void createMenu (long id , String name , List <MenuItem > menuItems ) {
177
178
Restaurant restaurant = new Restaurant (id , name , menuItems );
178
179
restaurantRepository .save (restaurant );
179
180
}
180
181
181
- @ Transactional (propagation = Propagation .MANDATORY )
182
182
public void reviseMenu (long id , List <MenuItem > menuItems ) {
183
183
restaurantRepository .findById (id ).map (restaurant -> {
184
184
List <OrderDomainEvent > events = restaurant .reviseMenu (menuItems );
0 commit comments