This commit is contained in:
Ino 2023-04-28 16:51:14 +04:00
parent 4f93068cce
commit c6889698bf

View File

@ -0,0 +1,26 @@
package com.example.demo.supply.Supplier;
import com.example.demo.supply.Product.ProductDto;
import com.example.demo.supply.Product.ProductService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;
@Controller
@RequestMapping("/product")
public class ProductMvcController {
private final ProductService productService;
public ProductMvcController(ProductService productService){ this.productService = productService;}
@GetMapping("/")
public String getProducts(Model model) {
model.addAttribute("students",
productService.findAllProducts().stream().map(ProductDto::new).toList());
return "students";
}
}