Commit 0b86eb81 authored by Khai Yuan ​Liew's avatar Khai Yuan ​Liew

[AFP-58] Work on DELETE product controller

parent 2762235b
...@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.GetMapping; ...@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@RestController @RestController
@RequestMapping("/api/products") @RequestMapping("/api/products")
...@@ -17,8 +18,10 @@ public class ProductController { ...@@ -17,8 +18,10 @@ public class ProductController {
ProductService productService; ProductService productService;
@DeleteMapping(value = "/{sku}") @DeleteMapping(value = "/{sku}")
public void deleteProduct(@PathVariable String sku) { public Mono<ResponseEntity<Void>> deleteProduct(@PathVariable String sku) {
productService.removeProductBySku(sku).subscribe(); return productService.removeProductBySku(sku)
.map( res -> ResponseEntity.ok().<Void>build())
.defaultIfEmpty(ResponseEntity.notFound().build());
} }
@GetMapping() @GetMapping()
......
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