Hexagonal Architecture with Spring Boot
This commit is contained in:
@@ -27,13 +27,7 @@ public class ProductService implements CreateProductUseCase, GetProductUseCase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Product getProductById(Long id) {
|
public Product getProductById(Long id) {
|
||||||
Optional<Product> product = productOutputPort.getProductById(id);
|
return productOutputPort.getProductById(id).orElseThrow(() -> new ProductNotFound("Product not found with id " + id));
|
||||||
|
|
||||||
if(product.isEmpty()) {
|
|
||||||
throw new ProductNotFound("Product not found with id " + id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return product.get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user