package com.nisum.springboot.controller; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.nisum.springboot.entity.Product; import com.nisum.springboot.service.ProductService; @RestController @RequestMapping("/products") public class ProductController { @Autowired private ProductService service; @PostMapping(consumes="application/json", produces="application/json") public Product saveProduct(@RequestBody Product product) { return service.saveProduct(product); } @GetMapping public List<Product> getAllProducts(){ return service.getAllProducts(); } @GetMapping("{productId}") public Product getProduct(@PathVariable String productId){ return service.getProduct(productId); } @PutMapping public Product updateProduct(@RequestBody Product product){ return service.updateProduct(product); } @DeleteMapping("{productId}") public String deleteProduct(@PathVariable String productId) { return service.deleteProduct(productId); } @GetMapping("/productName/{productName}") public List<Product> getProductName(@PathVariable String productName){ return service.getProductName(productName); } }