Skip to content

Commit b6ab94a

Browse files
exercise 3 sol
1 parent fc8280f commit b6ab94a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/main/java/com/amigoscode/product/ProductService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ public void updateProduct(UUID id,
9595
product.setStockLevel(updateRequest.stockLevel());
9696
}
9797

98+
if (updateRequest.isPublished() != null && !updateRequest.isPublished().equals(product.getPublished())) {
99+
product.setPublished(updateRequest.isPublished());
100+
}
101+
98102
productRepository.save(product);
99103
}
100104
}

src/main/java/com/amigoscode/product/UpdateProductRequest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public record UpdateProductRequest(
2828
BigDecimal price,
2929

3030
@Min(value = 1, message = "Min Stock Level is 1")
31-
Integer stockLevel
31+
Integer stockLevel,
32+
33+
Boolean isPublished
3234
) {
3335
}

0 commit comments

Comments
 (0)