198 lines
4.2 KiB
Java
198 lines
4.2 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.PathVariable;
|
|
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";
|
|
}
|
|
|
|
@GetMapping("/suppliers/{id}")
|
|
public String internListedArticlesId(Model model, @PathVariable String id) {
|
|
|
|
System.out.println("hEre!");
|
|
|
|
int supplierId = Integer.parseInt(id);
|
|
|
|
UImodelSupplierDetailOrders orders = new UImodelSupplierDetailOrders(supplierId, "01.01.1970", "orderd article",
|
|
"netto €", "42", "total €", "31.12.1970");
|
|
|
|
UImodelSupplierDetail total = new UImodelSupplierDetail(supplierRepository.findSupplierById(supplierId).name,
|
|
"42€", orders);
|
|
|
|
model.addAttribute("SupplierDetail", total);
|
|
|
|
return "intern/suppliers/id";
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
}
|
|
|
|
public class UImodelSupplierDetail {
|
|
|
|
String name;
|
|
String balance;
|
|
UImodelSupplierDetailOrders orders;
|
|
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
public void setName(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
public String getBalance() {
|
|
return balance;
|
|
}
|
|
|
|
public void setBalance(String balance) {
|
|
this.balance = balance;
|
|
}
|
|
|
|
public UImodelSupplierDetailOrders getOrders() {
|
|
return orders;
|
|
}
|
|
|
|
public void setOrders(UImodelSupplierDetailOrders orders) {
|
|
this.orders = orders;
|
|
}
|
|
|
|
public UImodelSupplierDetail(String name, String balance, UImodelSupplierDetailOrders orders) {
|
|
this.name = name;
|
|
this.balance = balance;
|
|
this.orders = orders;
|
|
}
|
|
|
|
}
|
|
|
|
public class UImodelSupplierDetailOrders {
|
|
long id;
|
|
String dateOrder;
|
|
String articleName;
|
|
String priceNetto;
|
|
String quantity;
|
|
String price_total;
|
|
String dateArrival;
|
|
|
|
public long getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(long id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public String getDateOrder() {
|
|
return dateOrder;
|
|
}
|
|
|
|
public void setDateOrder(String dateOrder) {
|
|
this.dateOrder = dateOrder;
|
|
}
|
|
|
|
public String getArticleName() {
|
|
return articleName;
|
|
}
|
|
|
|
public void setArticleName(String articleName) {
|
|
this.articleName = articleName;
|
|
}
|
|
|
|
public String getPriceNetto() {
|
|
return priceNetto;
|
|
}
|
|
|
|
public void setPriceNetto(String priceNetto) {
|
|
this.priceNetto = priceNetto;
|
|
}
|
|
|
|
public String getQuantity() {
|
|
return quantity;
|
|
}
|
|
|
|
public void setQuantity(String quantity) {
|
|
this.quantity = quantity;
|
|
}
|
|
|
|
public String getPrice_total() {
|
|
return price_total;
|
|
}
|
|
|
|
public void setPrice_total(String price_total) {
|
|
this.price_total = price_total;
|
|
}
|
|
|
|
public String getDateArrival() {
|
|
return dateArrival;
|
|
}
|
|
|
|
public void setDateArrival(String dateArrival) {
|
|
this.dateArrival = dateArrival;
|
|
}
|
|
|
|
public UImodelSupplierDetailOrders(long id, String dateOrder, String articleName, String priceNetto,
|
|
String quantity, String price_total, String dateArrival) {
|
|
this.id = id;
|
|
this.dateOrder = dateOrder;
|
|
this.articleName = articleName;
|
|
this.priceNetto = priceNetto;
|
|
this.quantity = quantity;
|
|
this.price_total = price_total;
|
|
this.dateArrival = dateArrival;
|
|
}
|
|
|
|
}
|
|
|
|
}
|