2020-04-29 22:44:16 +02:00
package org.hso.ecommerce.controller.intern.suppliers ;
2020-04-28 22:41:29 +02:00
2020-05-30 16:16:14 +02:00
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 ;
2020-04-28 22:41:29 +02:00
import org.springframework.stereotype.Controller ;
2020-05-30 16:16:14 +02:00
import org.springframework.ui.Model ;
import org.springframework.web.bind.annotation.GetMapping ;
2020-05-30 16:43:07 +02:00
import org.springframework.web.bind.annotation.PathVariable ;
2020-05-30 16:16:14 +02:00
import org.springframework.web.bind.annotation.RequestMapping ;
2020-04-28 22:41:29 +02:00
@Controller
2020-05-30 16:16:14 +02:00
@RequestMapping ( " /intern/ " )
2020-05-01 10:48:12 +02:00
public class SupplierIndexController {
2020-05-30 16:16:14 +02:00
@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 " ;
}
2020-05-30 16:43:07 +02:00
@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 " ;
}
2020-05-30 16:16:14 +02:00
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 ;
}
}
2020-05-30 16:43:07 +02:00
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 ;
}
}
2020-04-28 22:41:29 +02:00
}