Created
July 19, 2019 12:39
-
-
Save hpgrahsl/b9467e15a97bf7664b534c7213b0ef16 to your computer and use it in GitHub Desktop.
OrderService Class
This file contains hidden or 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
@Service | |
public class OrderService { | |
//... | |
@Transactional | |
public PurchaseOrder updateOrderLineStatus(long orderId, long orderLineId, OrderLineStatus newStatus) { | |
PurchaseOrder po = repository.findById(orderId) | |
.orElseThrow(() -> new EntityNotFoundException("order with id " + orderId + " doesn't exist!")); | |
OrderLineStatus oldStatus = po.updateOrderLine(orderLineId, newStatus); | |
eventBus.publishEvent(OrderLineUpdatedEvent.of(orderId, orderLineId, newStatus, oldStatus)); | |
repository.save(po); | |
return po; | |
} | |
//... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment