From 0d4b2dcf75166703a7f8a8c6324deecb7e5f8823 Mon Sep 17 00:00:00 2001 From: prgres Date: Sun, 13 Jan 2019 18:53:55 +0100 Subject: [PATCH] fix add endpoint --- .../dino/scrum/sysmag/controller/ProductController.java | 7 +++---- .../java/com/dino/scrum/sysmag/service/ProductService.java | 2 +- .../com/dino/scrum/sysmag/service/ProductServiceImpl.java | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/dino/scrum/sysmag/controller/ProductController.java b/src/main/java/com/dino/scrum/sysmag/controller/ProductController.java index 7b04499..3f0ce5e 100644 --- a/src/main/java/com/dino/scrum/sysmag/controller/ProductController.java +++ b/src/main/java/com/dino/scrum/sysmag/controller/ProductController.java @@ -42,16 +42,15 @@ public class ProductController { @PostMapping(value = "/product/add") public @ResponseBody - String addProduct(@RequestBody Product product){ - productService.addProduct(product); - return "Jak siÄ™ bawisz Kondradzie?"; + Product addProduct(@RequestBody Product product){ + return productService.addProduct(product); } @DeleteMapping(value = "/product/delete") public @ResponseBody String deleteProduct(@RequestBody IdDto id){ productService.deleteProduct(id.getId()); - return "(y)"; + return "Deleted" + id; } @GetMapping(value = "/product/get-by-id") diff --git a/src/main/java/com/dino/scrum/sysmag/service/ProductService.java b/src/main/java/com/dino/scrum/sysmag/service/ProductService.java index d288a6e..869e29e 100644 --- a/src/main/java/com/dino/scrum/sysmag/service/ProductService.java +++ b/src/main/java/com/dino/scrum/sysmag/service/ProductService.java @@ -15,6 +15,6 @@ public interface ProductService { Product changeQuantity(QuantityChange quantityChange); Product getById(Long id); float getPriceOfAllProducts(); - void addProduct(Product product); + Product addProduct(Product product); void deleteProduct(long id); } diff --git a/src/main/java/com/dino/scrum/sysmag/service/ProductServiceImpl.java b/src/main/java/com/dino/scrum/sysmag/service/ProductServiceImpl.java index d0a0318..1c77e15 100644 --- a/src/main/java/com/dino/scrum/sysmag/service/ProductServiceImpl.java +++ b/src/main/java/com/dino/scrum/sysmag/service/ProductServiceImpl.java @@ -63,8 +63,8 @@ public class ProductServiceImpl implements ProductService { } @Override - public void addProduct(Product product) { - productRepository.save(product); + public Product addProduct(Product product) { + return productRepository.save(product); } @Override