Commit 302331ab by Patryk Czarnik

Edycja produktu - parametry jako jeden obiekt

parent 62b9d6a8
......@@ -56,14 +56,11 @@ public class ProductController {
}
@PostMapping({"/{id}/edit", "/new"})
public String saveProduct(Integer productId, String productName, BigDecimal price, BigDecimal vat, String description,
public String saveProduct(Product product,
Model model) {
Product product = new Product();
product.setProductId(productId);
product.setProductName(productName);
product.setPrice(price);
product.setVat(vat);
product.setDescription(description);
// W tej wersji dane z wypełnionego formularza odbieramy w postaci jednego obiektu Product.
// Spring sam wpisze dane do pól o takich samych nazwach.
System.out.println("id przed zapisem: " + product.getProductId());
productRepository.save(product);
System.out.println("id po zapisie: " + product.getProductId());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment