Skip to content

Instantly share code, notes, and snippets.

@hpgrahsl
Created July 19, 2019 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hpgrahsl/b9467e15a97bf7664b534c7213b0ef16 to your computer and use it in GitHub Desktop.
Save hpgrahsl/b9467e15a97bf7664b534c7213b0ef16 to your computer and use it in GitHub Desktop.
OrderService Class
@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