Commit 235591df by Patryk Czarnik

getOneProduct

parent 13f7e9dd
package sklep.rest; package sklep.rest;
import java.util.List; import java.util.List;
import java.util.Optional;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import sklep.model.Product; import sklep.model.Product;
...@@ -18,8 +20,13 @@ public class ProductEndpoint { ...@@ -18,8 +20,13 @@ public class ProductEndpoint {
@GetMapping("/products") @GetMapping("/products")
public List<Product> getAllProducts() { public List<Product> getAllProducts() {
System.out.println("puk puk");
return productRepository.findAll(); return productRepository.findAll();
} }
@GetMapping("/products/{id}")
public Optional<Product> getOneProduct(@PathVariable("id") Integer id) {
return productRepository.findById(id);
}
} }
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