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 3602236..defeb1c 100644 --- a/prototype/src/main/java/org/hso/ecommerce/app/RequestController.java +++ b/prototype/src/main/java/org/hso/ecommerce/app/RequestController.java @@ -22,10 +22,10 @@ public class RequestController { static int notSoRandom = 0; - @GetMapping("/") - public String home() { - return "redirect:/shop/"; - } +// @GetMapping("/") +// public String home() { +// return "redirect:/shop/"; +// } @GetMapping("/login") public String login() { @@ -43,7 +43,7 @@ public class RequestController { String gto = (String) session.getAttribute("afterLogin"); Optional user = userRepository.findByEmail(username); - if (user.isEmpty()) { + if (!user.isPresent()) { request.setAttribute("error", "Email Adresse falsch."); response.setStatus(HttpServletResponse.SC_EXPECTATION_FAILED); return "login"; @@ -88,10 +88,10 @@ public class RequestController { return "redirect:/"; } - @GetMapping("/shop/") - public String shop() { - return "shop/index"; - } +// @GetMapping("/shop/") +// public String shop() { +// return "shop/index"; +// } @GetMapping("/shop/search") public String shopSearch() { @@ -137,20 +137,20 @@ public class RequestController { } } - @GetMapping("/about") - public String about() { - return "about"; - } - - @GetMapping("/terms") - public String terms() { - return "terms"; - } - - @GetMapping("/privacy") - public String privacy() { - return "privacy"; - } +// @GetMapping("/about") +// public String about() { +// return "about"; +// } +// +// @GetMapping("/terms") +// public String terms() { +// return "terms"; +// } +// +// @GetMapping("/privacy") +// public String privacy() { +// return "privacy"; +// } @GetMapping("/intern/") diff --git a/prototype/src/main/java/org/hso/ecommerce/controller/shop/ShopIndexController.java b/prototype/src/main/java/org/hso/ecommerce/controller/shop/ShopIndexController.java index 0f423db..5d442d6 100644 --- a/prototype/src/main/java/org/hso/ecommerce/controller/shop/ShopIndexController.java +++ b/prototype/src/main/java/org/hso/ecommerce/controller/shop/ShopIndexController.java @@ -1,8 +1,83 @@ package org.hso.ecommerce.controller.shop; +import org.hso.ecommerce.entities.shop.Article; 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 javax.swing.*; +import java.awt.*; +import java.util.ArrayList; @Controller -//@RequestMapping("...") +@RequestMapping("/") public class ShopIndexController { + + @GetMapping("/") + public String home() { + return "redirect:/shop/"; + } + + @GetMapping("/shop/") + public String shop(Model model) { + + ArrayList
dummyArticles = getArticles(); + + model.addAttribute("articles", dummyArticles); + return "shop/index"; + } + + @GetMapping("/about") + public String about() { + return "about"; + } + + @GetMapping("/terms") + public String terms() { + return "terms"; + } + + @GetMapping("/privacy") + public String privacy() { + return "privacy"; + } + + + + public ArrayList
getArticles(){ + ArrayList
dummyArticles = new ArrayList
(); + + Article d1 = new Article(); + d1.description = "this is dummy1"; + d1.title = "dummy1"; + d1.shopPricePerUnitNetCent = 1500; + d1.id = 1234; + dummyArticles.add(d1); + + Article d2 = new Article(); + d2.description = "this is dummy2"; + d2.title = "dummy2"; + d2.shopPricePerUnitNetCent = 2000; + d2.id = 2345; + dummyArticles.add(d2); + + Article d3 = new Article(); + d3.description = "this is dummy3"; + d3.title = "dummy3"; + d3.shopPricePerUnitNetCent = 2500; + d3.id = 3456; + dummyArticles.add(d3); + + Article d4 = new Article(); + d4.description = "this is dummy4"; + d4.title = "dummy4"; + d4.shopPricePerUnitNetCent = 3000; + d4.id = 4567; + dummyArticles.add(d4); + + return dummyArticles; + } + + } diff --git a/prototype/src/main/resources/templates/shop/index.html b/prototype/src/main/resources/templates/shop/index.html index 68a4a1f..a019c8a 100644 --- a/prototype/src/main/resources/templates/shop/index.html +++ b/prototype/src/main/resources/templates/shop/index.html @@ -18,54 +18,13 @@