From 5691f0eeec76af52cb7ffb85cbe81ac837aceef6 Mon Sep 17 00:00:00 2001 From: Hannes Date: Wed, 3 Jun 2020 20:26:36 +0200 Subject: [PATCH] implement customers index --- .../customers/CustomersIndexController.java | 40 +++------ .../templates/intern/customers/index.html | 89 +++---------------- 2 files changed, 24 insertions(+), 105 deletions(-) diff --git a/prototype/src/main/java/org/hso/ecommerce/controller/intern/customers/CustomersIndexController.java b/prototype/src/main/java/org/hso/ecommerce/controller/intern/customers/CustomersIndexController.java index cbda950..d776274 100644 --- a/prototype/src/main/java/org/hso/ecommerce/controller/intern/customers/CustomersIndexController.java +++ b/prototype/src/main/java/org/hso/ecommerce/controller/intern/customers/CustomersIndexController.java @@ -1,46 +1,34 @@ package org.hso.ecommerce.controller.intern.customers; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; - -import org.hso.ecommerce.controller.intern.accounting.AccountingController; -import org.hso.ecommerce.controller.intern.accounting.AccountingController.ShortTemplateBookingResult; -import org.hso.ecommerce.entities.booking.Booking; -import org.hso.ecommerce.repos.booking.BookingRepository; +import org.hso.ecommerce.entities.user.User; +import org.hso.ecommerce.repos.user.UserRepository; 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; +import java.util.List; + @Controller @RequestMapping("/intern/customers") public class CustomersIndexController { @Autowired - private BookingRepository bookingRepository = null; + private final UserRepository userRepository = null; - @Autowired - private AccountingController accountingController = null; + @GetMapping("") + public String internCustomers(Model model) { + + List users = userRepository.findAll(); + + model.addAttribute("users", users); - @GetMapping("/") - public String internCustomers() { return "intern/customers/index"; } - @GetMapping("/{customerId}") - public String internCustomersId(HttpServletRequest request, @PathVariable(required = true) long customerId) { - - // Table of bookings - List bookings = bookingRepository.customerBookingsReverseChronologically(customerId); - ShortTemplateBookingResult result = accountingController.buildShortTemplate( - bookings, - account -> account.userAccount != null && account.userAccount.id == customerId); - request.setAttribute("balance", result.balance); - request.setAttribute("bookings", result.bookings); - + @GetMapping("/{id}") + public String internCustomersId() { return "intern/customers/id"; } - } diff --git a/prototype/src/main/resources/templates/intern/customers/index.html b/prototype/src/main/resources/templates/intern/customers/index.html index 4c5d773..cd95093 100644 --- a/prototype/src/main/resources/templates/intern/customers/index.html +++ b/prototype/src/main/resources/templates/intern/customers/index.html @@ -39,85 +39,16 @@ Status - - 1209 - 2019-11-10 - Hans Maier - hans.maier@example.com - Geschäftskunde - Details - - - 1208 - 2019-11-10 - Hans Maier - hans.maier@example.com - Inaktiv, Geschäftskunde - Details - - - 1207 - 2019-11-10 - Hans Maier - hans.maier@example.com - - Details - - - 1206 - 2019-11-10 - Hans Maier - hans.maier@example.com - - Details - - - 1205 - 2019-11-10 - Hans Maier - hans.maier@example.com - - Details - - - 1204 - 2019-11-10 - Hans Maier - hans.maier@example.com - - Details - - - 1203 - 2019-11-10 - Hans Maier - hans.maier@example.com - - Details - - - 1202 - 2019-11-10 - Hans Maier - hans.maier@example.com - - Details - - - 1201 - 2019-11-10 - Hans Maier - hans.maier@example.com - Inaktiv, Mitarbeiter - Details - - - 1214 - 2019-11-10 - Hans Maier - admin@example.com - Mitarbeiter - Details + + + + + + + + + + Details