Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
package org.smarttechie.controller;
import org.smarttechie.model.Product;
import org.smarttechie.repository.ProductRepository;
import org.smarttechie.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
public class ProductController {
private ProductService productService;
* This endpoint allows to create a product.
* @param product - to create
* @return - the created product
public Mono<Product> createProduct(@RequestBody Product product){
* This endpoint gives all the products
* @return - the list of products available
public Flux<Product> getAllProducts(){
return productService.getAllProducts();
* This endpoint allows to delete a product
* @param id - to delete
* @return
public Mono<Void> deleteProduct(@PathVariable int id){
return productService.deleteProduct(id);
* This endpoint allows to update a product
* @param product - to update
* @return - the updated product
public Mono<ResponseEntity<Product>> updateProduct(@RequestBody Product product){
return productService.update(product);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment