Commit d321aeed authored by Khai Yuan ​Liew's avatar Khai Yuan ​Liew

[AFP-57] Work on PUT product endpoint

parent 66d5f1fc
...@@ -41,16 +41,13 @@ public class ProductController { ...@@ -41,16 +41,13 @@ public class ProductController {
return ResponseEntity.ok(productService.findAllProducts()); return ResponseEntity.ok(productService.findAllProducts());
} }
// @PutMapping("/{userId}") // @PutMapping("/{sku}")
// public Mono<ResponseEntity<Product>> updateProduct(@PathVariable String sku, @RequestBody Product product){ // public Mono<ResponseEntity<Product>> updateProduct(@PathVariable String sku, @RequestBody Product product){
// return productService.updateProductBySku(sku,user) // return productService.updateProductBySku(sku,user)
// .map(updatedProduct -> ResponseEntity.ok(updatedProduct)) // .map(updatedProduct -> ResponseEntity.ok(updatedProduct))
// .defaultIfEmpty(ResponseEntity.badRequest().build()); // .defaultIfEmpty(ResponseEntity.badRequest().build());
// } // }
}
@PostMapping("") @PostMapping("")
public Mono<ProductDto> postProduct(@RequestBody Product product) { public Mono<ProductDto> postProduct(@RequestBody Product product) {
return productService.createProduct(product).onErrorMap(throwable -> new ResourceAlreadyExistsException()); return productService.createProduct(product).onErrorMap(throwable -> new ResourceAlreadyExistsException());
......
...@@ -51,7 +51,6 @@ public class ProductService { ...@@ -51,7 +51,6 @@ public class ProductService {
}); });
} }
public Mono<ProductDto> createProduct(Product product) { public Mono<ProductDto> createProduct(Product product) {
return productRepository.save(product) return productRepository.save(product)
.map(ProductDto::generateDtoFromProduct); .map(ProductDto::generateDtoFromProduct);
......
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