implement getCustomerOrder

This commit is contained in:
Hannes Huber 2020-06-01 11:31:12 +02:00
parent 1a1502b38c
commit 2394157be8
4 changed files with 36 additions and 42 deletions

View File

@ -90,16 +90,6 @@ public class RequestController {
return "intern/customers/id";
}
@GetMapping("/intern/customerOrders/")
public String internCustomerOrder() {
return "intern/customerOrders/index";
}
@GetMapping("/intern/customerOrders/{id}")
public String internCustomerOrdersId() {
return "intern/customerOrders/id";
}
@GetMapping("/intern/suppliers/")
public String internSuppliers() {
return "intern/suppliers/index";

View File

@ -1,8 +1,31 @@
package org.hso.ecommerce.controller.intern.customers;
import org.hso.ecommerce.entities.shop.CustomerOrder;
import org.hso.ecommerce.repos.shop.CustomerOderRepository;
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;
import java.util.List;
@Controller
//@RequestMapping("...")
@RequestMapping("intern/customerOrders")
public class CustomerOrderController {
@Autowired
private final CustomerOderRepository customerOrderRepository = null;
@GetMapping("")
public String internCustomerOrder(Model model) {
List<CustomerOrder> orders = customerOrderRepository.getAllOrders();
model.addAttribute("orders", orders);
return "intern/customerOrders/index";
}
@GetMapping("/{id}")
public String internCustomerOrdersId() {
return "intern/customerOrders/id";
}
}

View File

@ -5,6 +5,8 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface CustomerOderRepository extends JpaRepository<CustomerOrder, Long> {
@ -13,5 +15,7 @@ public interface CustomerOderRepository extends JpaRepository<CustomerOrder, Lon
long articleId, java.sql.Timestamp begin, java.sql.Timestamp end
);
@Query("SELECT co FROM CustomerOrder co ORDER BY co.created DESC")
List<CustomerOrder> getAllOrders();
}

View File

@ -40,37 +40,14 @@
<th>Status</th>
<th></th>
</tr>
<tr>
<td><a th:href="@{/intern/customers/48584}">101</a></td>
<td>440</td>
<td>2019-12-54</td>
<td>10,13&nbsp;EUR</td>
<td>Zugestellt</td>
<td><a th:href="@{/intern/customerOrders/48584}" class="button smaller">Details</a></td>
</tr>
<tr>
<td><a th:href="@{/intern/customers/48584}">102</a></td>
<td>241</td>
<td>2019-11-10</td>
<td>40,13&nbsp;EUR</td>
<td>In Zustellung</td>
<td><a th:href="@{/intern/customerOrders/48584}" class="button smaller">Details</a></td>
</tr>
<tr>
<td><a th:href="@{/intern/customers/48584}">101</a></td>
<td>241</td>
<td>2019-11-10</td>
<td>10,13&nbsp;EUR</td>
<td>Erfasst</td>
<td><a th:href="@{/intern/customerOrders/48584}" class="button smaller">Details</a></td>
</tr>
<tr>
<td><a th:href="@{/intern/customers/48584}">755</a></td>
<td>544</td>
<td>2019-12-10</td>
<td>45,13&nbsp;EUR</td>
<td>Erfasst</td>
<td><a th:href="@{/intern/customerOrders/48584}" class="button smaller">Details</a></td>
<tr th:each="order: ${orders}">
<td><a th:href="@{/intern/customers/48584}" th:text="${order.customer.id}">101</a></td>
<td th:text="${order.id}"></td>
<td th:text="${order.created.toString().substring(0, 10)}"></td>
<td th:text="${#numbers.formatDecimal(order.totalGrossCent, 1, 'POINT', 2, 'COMMA')}"></td>
<td th:if="${order.deliveredAt == null}">In Zustellung</td>
<td th:if="${order.deliveredAt != null}">Zugestellt</td>
<td><a th:href="@{/intern/customerOrders/{id}(id=${order.id})}" class="button smaller">Details</a></td>
</tr>
</table>
</p>