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