BAEL-7143: fixed formatting
This commit is contained in:
parent
920dc80c41
commit
a2ca867a58
|
@ -26,7 +26,7 @@ class ProductService {
|
|||
|
||||
private void computePriceAndPublishMessage(String productId, String cartId) {
|
||||
Product product = repository.findById(productId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("not found!"));
|
||||
.orElseThrow(() -> new IllegalArgumentException("not found!"));
|
||||
|
||||
Price price = computePrice(productId, product);
|
||||
|
||||
|
@ -35,11 +35,9 @@ class ProductService {
|
|||
}
|
||||
|
||||
private Price computePrice(String productId, Product product) {
|
||||
if (product.category()
|
||||
.isEligibleForDiscount()) {
|
||||
if (product.category().isEligibleForDiscount()) {
|
||||
BigDecimal discount = discountService.discountForProduct(productId);
|
||||
return product.basePrice()
|
||||
.applyDiscount(discount);
|
||||
return product.basePrice().applyDiscount(discount);
|
||||
}
|
||||
return product.basePrice();
|
||||
}
|
||||
|
|
|
@ -22,17 +22,16 @@ class ProductService {
|
|||
|
||||
public void addProductToCart(String productId, String cartId) {
|
||||
repository.findById(productId)
|
||||
.switchIfEmpty(Mono.error(() -> new IllegalArgumentException("not found!")))
|
||||
.flatMap(this::computePrice)
|
||||
.map(price -> new ProductAddedToCartEvent(productId, price.value(), price.currency(), cartId))
|
||||
.subscribe(event -> kafkaTemplate.send(PRODUCT_ADDED_TO_CART_TOPIC, cartId, event));
|
||||
.switchIfEmpty(Mono.error(() -> new IllegalArgumentException("not found!")))
|
||||
.flatMap(this::computePrice)
|
||||
.map(price -> new ProductAddedToCartEvent(productId, price.value(), price.currency(), cartId))
|
||||
.subscribe(event -> kafkaTemplate.send(PRODUCT_ADDED_TO_CART_TOPIC, cartId, event));
|
||||
}
|
||||
|
||||
private Mono<Price> computePrice(Product product) {
|
||||
if (product.category()
|
||||
.isEligibleForDiscount()) {
|
||||
if (product.category().isEligibleForDiscount()) {
|
||||
return discountService.discountForProduct(product.id())
|
||||
.map(product.basePrice()::applyDiscount);
|
||||
.map(product.basePrice()::applyDiscount);
|
||||
}
|
||||
return Mono.just(product.basePrice());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue