list suppliers page

This commit is contained in:
Hendrik Schutter 2020-05-30 16:16:14 +02:00
parent 1b2e75a82c
commit c8d3ab3ff0
4 changed files with 115 additions and 72 deletions

View File

@ -100,11 +100,12 @@ public class RequestController {
return "intern/customerOrders/id"; return "intern/customerOrders/id";
} }
/*
@GetMapping("/intern/suppliers/") @GetMapping("/intern/suppliers/")
public String internSuppliers() { public String internSuppliers() {
return "intern/suppliers/index"; return "intern/suppliers/index";
} }
*/
@GetMapping("/intern/suppliers/{id}") @GetMapping("/intern/suppliers/{id}")
public String internSuppliersId() { public String internSuppliersId() {
return "intern/suppliers/id"; return "intern/suppliers/id";
@ -120,15 +121,6 @@ public class RequestController {
return "intern/supplierOrders/id"; return "intern/supplierOrders/id";
} }
/*
@GetMapping("/intern/suppliersOffers")
public String internSuppliersOffers() {
return "intern/offeredArticles/index";
}
*/
@GetMapping("/intern/accounting/") @GetMapping("/intern/accounting/")
public String accounting() { public String accounting() {
return "intern/accounting/index"; return "intern/accounting/index";

View File

@ -1,8 +1,62 @@
package org.hso.ecommerce.controller.intern.suppliers; 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.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller @Controller
//@RequestMapping("...") @RequestMapping("/intern/")
public class SupplierIndexController { 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;
}
}
} }

View File

@ -1,10 +1,18 @@
package org.hso.ecommerce.repos.supplier; package org.hso.ecommerce.repos.supplier;
import java.util.List;
import org.hso.ecommerce.entities.supplier.Supplier; import org.hso.ecommerce.entities.supplier.Supplier;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@Repository @Repository
public interface SupplierRepository extends JpaRepository<Supplier, Long> { public interface SupplierRepository extends JpaRepository<Supplier, Long> {
@Query("SELECT a FROM Supplier a")
List<Supplier> findAll();
} }

View File

@ -1,63 +1,52 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="de" dir="ltr" xmlns:th="http://www.thymeleaf.org"> <html lang="de" dir="ltr" xmlns:th="http://www.thymeleaf.org">
<head>
<head> <meta charset="utf-8">
<meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=0.75, user-scalable=no">
<meta name="viewport" content="width=device-width, initial-scale=0.75, user-scalable=no"> <title>Lieferanten</title>
<script th:src="@{/js/filterTable.js}"></script>
<title>Lieferanten</title> <link rel="stylesheet" th:href="@{/css/ecom.css}"/>
<script th:src="@{/js/filterTable.js}"></script> </head>
<link rel="stylesheet" th:href="@{/css/ecom.css}"/> <body>
</head> <nav th:replace="fragments/header :: header">Header</nav>
<div class="sidebar-layout content-width">
<body> <nav></nav>
<nav th:replace="fragments/header :: header">Header</nav> <div>
<div class="sidebar-layout content-width"> <h1>Lieferanten</h1>
<nav></nav> <script th:src="@{/js/back.js}"></script>
<div> <div class="back" data-group="intern" data-name="Zurück zur Übersicht der Lieferanten."
<h1>Lieferanten</h1> data-insert="false"></div>
</div>
<script th:src="@{/js/back.js}"></script> </div>
<div class="back" data-group="intern" data-name="Zurück zur Übersicht der Lieferanten." <main class="sidebar-layout content-width">
data-insert="false"></div> <nav th:replace="fragments/intern :: sidebar"></nav>
</div> <div class="content-width">
</div> <p>
<main class="sidebar-layout content-width"> <table id="main-table">
<nav th:replace="fragments/intern :: sidebar"></nav> <tr>
<div class="content-width"> <th colspan="7">
<p> <input type="text" placeholder="Filtern" class="smaller jsFilterTable full-width"
<table id="main-table"> data-target-id="main-table"></input>
<tr> </th>
<th colspan="7"> </tr>
<input type="text" placeholder="Filtern" class="smaller jsFilterTable full-width" <thead>
data-target-id="main-table"></input> <tr>
</th> <th>Nr</th>
</tr> <th>Name</th>
<tr> <th></th>
<th>Nr</th> </tr>
<th>Name</th> </thead>
<th></th> <tbody>
</tr> <tr th:each="supplier : ${suppliers}">
<tr> <td><span th:text="${supplier.id}"></span></td>
<td>0015</td> <td><span th:text="${supplier.name}"></span></td>
<td>Cheap AG</td> <td><a th:href="@{/intern/suppliers/{id}(id = ${supplier.id})}" class="button smaller">Details</a></td>
<td><a th:href="@{/intern/suppliers/4884}" class="button smaller">Details</a></td> </tr>
</tr> </tbody>
<tr> </table>
<td>5012</td> </p>
<td>Not Cheap GmbH & Co. KG</td> </div>
<td><a th:href="@{/intern/suppliers/4884}" class="button smaller">Details</a></td> </main>
</tr> <footer th:replace="fragments/footer :: footer"></footer>
<tr> </body>
<td>7400</td> </html>
<td>Hans MÜller GmbH</td>
<td><a th:href="@{/intern/suppliers/4884}" class="button smaller">Details</a></td>
</tr>
</table>
</p>
</div>
</main>
<footer th:replace="fragments/footer :: footer"></footer>
</body>
</html>