This repository has been archived on 2020-08-02. You can view files and clone it, but cannot push or open issues or pull requests.
e-commerce/prototype/src/main/java/org/hso/ecommerce/controller/intern/suppliers/SupplierIndexController.java

63 lines
1.4 KiB
Java

package org.hso.ecommerce.controller.intern.suppliers;
import java.util.ArrayList;
import java.util.List;
import org.hso.ecommerce.entities.supplier.Supplier;
import org.hso.ecommerce.repos.supplier.SupplierRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/intern/")
public class SupplierIndexController {
@Autowired
private final SupplierRepository supplierRepository = null;
@GetMapping("suppliers")
public String listSuppliers(Model model) {
List<UImodelSuppliers> totals = new ArrayList<UImodelSuppliers>();
for (Supplier supplier : supplierRepository.findAll()) {
UImodelSuppliers tmp = new UImodelSuppliers(supplier.id, supplier.name);
totals.add(tmp);
}
model.addAttribute("suppliers", totals);
return "intern/suppliers/index";
}
public class UImodelSuppliers {
long id;
String name;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public UImodelSuppliers(long id, String name) {
this.id = id;
this.name = name;
}
}
}