From 6ab3b63923d6d2dea0d50eb906b63a0ea94af1b8 Mon Sep 17 00:00:00 2001 From: Seil0 Date: Fri, 1 May 2020 14:53:35 +0200 Subject: [PATCH] Revert "split RequestController acording to mapping" This reverts commit 41eb4d0b8faf75bac244f8f7d13c8ce75971cc86. --- .../hso/ecommerce/app/RequestController.java | 172 ++++++++++++++++++ .../user => app}/UserRequestController.java | 2 +- .../intern/InternRequestController.java | 137 -------------- .../shop/ShopRequestController.java | 63 ------- 4 files changed, 173 insertions(+), 201 deletions(-) rename prototype/src/main/java/org/hso/ecommerce/{controller/user => app}/UserRequestController.java (94%) delete mode 100644 prototype/src/main/java/org/hso/ecommerce/controller/intern/InternRequestController.java delete mode 100644 prototype/src/main/java/org/hso/ecommerce/controller/shop/ShopRequestController.java diff --git a/prototype/src/main/java/org/hso/ecommerce/app/RequestController.java b/prototype/src/main/java/org/hso/ecommerce/app/RequestController.java index a2189e6..3602236 100644 --- a/prototype/src/main/java/org/hso/ecommerce/app/RequestController.java +++ b/prototype/src/main/java/org/hso/ecommerce/app/RequestController.java @@ -20,6 +20,8 @@ public class RequestController { @Autowired private final UserRepository userRepository = null; + static int notSoRandom = 0; + @GetMapping("/") public String home() { return "redirect:/shop/"; @@ -86,6 +88,55 @@ public class RequestController { return "redirect:/"; } + @GetMapping("/shop/") + public String shop() { + return "shop/index"; + } + + @GetMapping("/shop/search") + public String shopSearch() { + return "shop/search"; + } + + @GetMapping("/shop/checkout") + public String shopCheckout(HttpSession session, HttpServletRequest request) { + session.setAttribute("afterLogin", request.getRequestURI()); + return "shop/checkout"; + } + + @PostMapping("/shop/checkoutFinish") + public String shopCheckoutFinish() { + return "shop/checkoutFinish"; + } + + @GetMapping("/shop/checkoutFinish") + public String shopCheckoutFinishGET() { + return "shop/checkoutFinish"; + } + + @GetMapping("/shop/articles/{id}") + public String shopArticlesById() { + return "shop/articles/id"; + } + + @PostMapping("/shop/articles/{id}") + public String shopArticlesByIdBuy(HttpSession session, + @RequestAttribute(value = "user", required = false) User customer, + @PathVariable("id") Integer id, + @RequestParam("fastcheckout") Boolean fastcheckout + ) { + if (customer != null) { + if (!fastcheckout) { + return "shop/articles/post_add"; + } else { + return "shop/checkout"; + } + } else { + session.setAttribute("afterLogin", "/shop/articles/" + id); + return "redirect:/login"; + } + } + @GetMapping("/about") public String about() { return "about"; @@ -101,4 +152,125 @@ public class RequestController { return "privacy"; } + + @GetMapping("/intern/") + public String intern() { + return "intern/index"; + } + + @GetMapping("/intern/listedArticles/") + public String internListedArticles() { + return "intern/listedArticles/index"; + } + + @GetMapping("/intern/listedArticles/{id}") + public String internListedArticlesId() { + return "intern/listedArticles/id"; + } + + + @GetMapping("/intern/articles/") + public String internArticles() { + return "intern/articles/index"; + } + + @GetMapping("/intern/articles/{id}") + public String internArticlesId() { + return "intern/articles/id"; + } + + @GetMapping("/intern/customers/") + public String internCustomers() { + return "intern/customers/index"; + } + + @GetMapping("/intern/customers/{id}") + public String internCustomersId() { + 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"; + } + + @GetMapping("/intern/suppliers/{id}") + public String internSuppliersId() { + return "intern/suppliers/id"; + } + + @GetMapping("/intern/supplierOrders/") + public String internSupplierOrders() { + return "intern/supplierOrders/index"; + } + + @GetMapping("/intern/supplierOrders/{id}") + public String internSupplierOrdersId() { + return "intern/supplierOrders/id"; + } + + @GetMapping("/intern/accounting/") + public String accounting() { + return "intern/accounting/index"; + } + + @GetMapping("/intern/accounting/vat") + public String accountingVat() { + return "intern/accounting/vat"; + } + + @GetMapping("/intern/accounting/main") + public String accountingIntern() { + return "intern/accounting/main"; + } + + @GetMapping("/intern/accounting/addManual") + public String accountingAddManual() { + return "intern/accounting/addManual"; + } + + @GetMapping("/intern/warehouse/") + public String accountingWarehouse() { + return "intern/warehouse/index"; + } + + @GetMapping("/intern/warehouse/todo") + public String accountingWarehouseTodo() { + return "intern/warehouse/todo"; + } + + @GetMapping("/intern/warehouse/addManual") + public String accountingWarehouseAddManual() { + return "intern/warehouse/addManual"; + } + + @PostMapping("/intern/warehouse/progress/{id}") + public String accountingWarehouseProgressIdPost(HttpServletResponse response) { + if ((notSoRandom++) % 2 == 1) { + return "redirect:/intern/warehouse/progress/450"; + } else { + response.setStatus(409); + return "intern/warehouse/error_progress_failed"; + } + } + + @GetMapping("/intern/warehouse/progress/{id}") + public String accountingWarehouseProgressId() { + return "intern/warehouse/id_progress"; + } + + @GetMapping("/intern/warehouse/slots/") + public String accountingWarehouseSlots() { + return "intern/warehouse/slots/index"; + } } diff --git a/prototype/src/main/java/org/hso/ecommerce/controller/user/UserRequestController.java b/prototype/src/main/java/org/hso/ecommerce/app/UserRequestController.java similarity index 94% rename from prototype/src/main/java/org/hso/ecommerce/controller/user/UserRequestController.java rename to prototype/src/main/java/org/hso/ecommerce/app/UserRequestController.java index f5368e7..c4f6301 100644 --- a/prototype/src/main/java/org/hso/ecommerce/controller/user/UserRequestController.java +++ b/prototype/src/main/java/org/hso/ecommerce/app/UserRequestController.java @@ -1,4 +1,4 @@ -package org.hso.ecommerce.controller.user; +package org.hso.ecommerce.app; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; diff --git a/prototype/src/main/java/org/hso/ecommerce/controller/intern/InternRequestController.java b/prototype/src/main/java/org/hso/ecommerce/controller/intern/InternRequestController.java deleted file mode 100644 index 94f9a8c..0000000 --- a/prototype/src/main/java/org/hso/ecommerce/controller/intern/InternRequestController.java +++ /dev/null @@ -1,137 +0,0 @@ -package org.hso.ecommerce.controller.intern; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; - -import javax.servlet.http.HttpServletResponse; - -@Controller -@RequestMapping("intern") -public class InternRequestController { - - static int notSoRandom = 0; - - @GetMapping("/") - public String intern() { - return "intern/index"; - } - - @GetMapping("/listedArticles/") - public String internListedArticles() { - return "intern/listedArticles/index"; - } - - @GetMapping("/listedArticles/{id}") - public String internListedArticlesId() { - return "intern/listedArticles/id"; - } - - - @GetMapping("/articles/") - public String internArticles() { - return "intern/articles/index"; - } - - @GetMapping("/articles/{id}") - public String internArticlesId() { - return "intern/articles/id"; - } - - @GetMapping("/customers/") - public String internCustomers() { - return "intern/customers/index"; - } - - @GetMapping("/customers/{id}") - public String internCustomersId() { - return "intern/customers/id"; - } - - @GetMapping("/customerOrders/") - public String internCustomerOrder() { - return "intern/customerOrders/index"; - } - - @GetMapping("/customerOrders/{id}") - public String internCustomerOrdersId() { - return "intern/customerOrders/id"; - } - - @GetMapping("/suppliers/") - public String internSuppliers() { - return "intern/suppliers/index"; - } - - @GetMapping("/suppliers/{id}") - public String internSuppliersId() { - return "intern/suppliers/id"; - } - - @GetMapping("/supplierOrders/") - public String internSupplierOrders() { - return "intern/supplierOrders/index"; - } - - @GetMapping("/supplierOrders/{id}") - public String internSupplierOrdersId() { - return "intern/supplierOrders/id"; - } - - @GetMapping("/accounting/") - public String accounting() { - return "intern/accounting/index"; - } - - @GetMapping("/accounting/vat") - public String accountingVat() { - return "intern/accounting/vat"; - } - - @GetMapping("/accounting/main") - public String accountingIntern() { - return "intern/accounting/main"; - } - - @GetMapping("/accounting/addManual") - public String accountingAddManual() { - return "intern/accounting/addManual"; - } - - @GetMapping("/warehouse/") - public String accountingWarehouse() { - return "intern/warehouse/index"; - } - - @GetMapping("/warehouse/todo") - public String accountingWarehouseTodo() { - return "intern/warehouse/todo"; - } - - @GetMapping("/warehouse/addManual") - public String accountingWarehouseAddManual() { - return "intern/warehouse/addManual"; - } - - @PostMapping("/warehouse/progress/{id}") - public String accountingWarehouseProgressIdPost(HttpServletResponse response) { - if ((notSoRandom++) % 2 == 1) { - return "redirect:/intern/warehouse/progress/450"; - } else { - response.setStatus(409); - return "intern/warehouse/error_progress_failed"; - } - } - - @GetMapping("/warehouse/progress/{id}") - public String accountingWarehouseProgressId() { - return "intern/warehouse/id_progress"; - } - - @GetMapping("/warehouse/slots/") - public String accountingWarehouseSlots() { - return "intern/warehouse/slots/index"; - } - -} diff --git a/prototype/src/main/java/org/hso/ecommerce/controller/shop/ShopRequestController.java b/prototype/src/main/java/org/hso/ecommerce/controller/shop/ShopRequestController.java deleted file mode 100644 index 7632b2a..0000000 --- a/prototype/src/main/java/org/hso/ecommerce/controller/shop/ShopRequestController.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.hso.ecommerce.controller.shop; - -import org.hso.ecommerce.entities.user.User; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.*; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; - -@Controller -@RequestMapping("shop") -public class ShopRequestController { - - @GetMapping("/") - public String shop() { - return "shop/index"; - } - - @GetMapping("/search") - public String shopSearch() { - return "shop/search"; - } - - @GetMapping("/checkout") - public String shopCheckout(HttpSession session, HttpServletRequest request) { - session.setAttribute("afterLogin", request.getRequestURI()); - return "shop/checkout"; - } - - @PostMapping("/checkoutFinish") - public String shopCheckoutFinish() { - return "shop/checkoutFinish"; - } - - @GetMapping("/checkoutFinish") - public String shopCheckoutFinishGET() { - return "shop/checkoutFinish"; - } - - @GetMapping("/articles/{id}") - public String shopArticlesById() { - return "shop/articles/id"; - } - - @PostMapping("/articles/{id}") - public String shopArticlesByIdBuy(HttpSession session, - @RequestAttribute(value = "user", required = false) User customer, - @PathVariable("id") Integer id, - @RequestParam("fastcheckout") Boolean fastcheckout - ) { - if (customer != null) { - if (!fastcheckout) { - return "shop/articles/post_add"; - } else { - return "shop/checkout"; - } - } else { - session.setAttribute("afterLogin", "/shop/articles/" + id); - return "redirect:/login"; - } - } - -}