Commit 6a719bf6 by Patryk Czarnik

REST za pomocą @ResponseBody

parent a349f74b
package sklep.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import sklep.model.Product;
public interface ProductRepository extends JpaRepository<Product, Integer> {
}
package sklep.rest;
import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import sklep.model.Product;
import sklep.repository.ProductRepository;
@Controller
public class ProductEndpoint {
private ProductRepository productRepository;
public ProductEndpoint(ProductRepository productRepository) {
this.productRepository = productRepository;
}
@GetMapping("/products")
@ResponseBody
public List<Product> getAllProducts() {
System.out.println("puk puk");
return productRepository.findAll();
}
}
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