Commit 414835df by Patryk Czarnik

findByProductName

parent 27822aae
......@@ -38,5 +38,11 @@ public class ProductController {
return "missing_product";
}
}
@GetMapping("/szukaj")
public String wyszukajProdukty(@RequestParam String name, Model model) {
List<Product> products = productRepository.findByProductName(name);
model.addAttribute("products", products);
return "products";
}
}
package sklep.repository;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
......@@ -8,4 +10,6 @@ import sklep.model.Product;
@Repository
public interface ProductRepository extends JpaRepository<Product, Integer> {
List<Product> findByProductName(String name);
}
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