diff --git a/prototype/src/main/java/org/hso/ecommerce/app/UserRequestController.java b/prototype/src/main/java/org/hso/ecommerce/app/UserRequestController.java deleted file mode 100644 index c4f6301..0000000 --- a/prototype/src/main/java/org/hso/ecommerce/app/UserRequestController.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.hso.ecommerce.app; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; - -@Controller -@RequestMapping("user") -public class UserRequestController { - - @GetMapping("/") - public String user() { - return "redirect:/user/settings"; - } - - @GetMapping("/settings") - public String userSettings() { - return "user/settings"; - } - - @GetMapping("/orders/") - public String userOrdeers() { - return "user/orders/index"; - } - - @GetMapping("/bonuspoints") - public String userBonuspoints() { - return "user/bonuspoints"; - } - - @GetMapping("/notifications/") - public String userNotifications() { - return "user/notifications/index"; - } -} - diff --git a/prototype/src/main/java/org/hso/ecommerce/controller/UserController.java b/prototype/src/main/java/org/hso/ecommerce/controller/UserController.java index 523bf2e..c462bd0 100644 --- a/prototype/src/main/java/org/hso/ecommerce/controller/UserController.java +++ b/prototype/src/main/java/org/hso/ecommerce/controller/UserController.java @@ -1,8 +1,55 @@ package org.hso.ecommerce.controller; +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.RequestMapping; + +import javax.servlet.http.HttpSession; @Controller -//@RequestMapping("...") +@RequestMapping("/user") public class UserController { + + @Autowired + private final UserRepository userRepository = null; + + @GetMapping("/") + public String user() { + return "redirect:/user/settings"; + } + + @GetMapping("/settings") + public String userSettings(Model model, + HttpSession session + ) { + long userId = (long) session.getAttribute("userId"); + User user = userRepository.findById(userId).get(); + model.addAttribute("user", user); + + //TODO: klären wegen Geschäftskundenunterscheidung + + return "user/settings"; + } + + @GetMapping("/notifications/") + public String userNotifications() { + return "user/notifications/index"; + } + + @GetMapping("/orders/") + public String userOrdeers() { + return "user/orders/index"; + } + +// @GetMapping("/bonuspoints") +// public String userBonuspoints() { +// return "user/bonuspoints"; +// } + + + } diff --git a/prototype/src/main/java/org/hso/ecommerce/entities/user/User.java b/prototype/src/main/java/org/hso/ecommerce/entities/user/User.java index 784d89a..c36b629 100644 --- a/prototype/src/main/java/org/hso/ecommerce/entities/user/User.java +++ b/prototype/src/main/java/org/hso/ecommerce/entities/user/User.java @@ -24,10 +24,16 @@ public class User { @Column(unique = true) public String email; + @Column(insertable=false, updatable = false) + public String name; + + public String salutation; + public String passwordHash; public boolean isActive; public boolean isEmployee; + public boolean isAdvertisementActivated; @Embedded public Address defaultDeliveryAddress; diff --git a/prototype/src/main/resources/templates/user/settings.html b/prototype/src/main/resources/templates/user/settings.html index 29f6ec4..682a3bb 100644 --- a/prototype/src/main/resources/templates/user/settings.html +++ b/prototype/src/main/resources/templates/user/settings.html @@ -27,7 +27,7 @@
- +
@@ -59,7 +59,7 @@
-
-
@@ -78,17 +78,14 @@
+ placeholder="Optional: Zusatz Optional: Unternehmen Straße Hausnummer Postleitzeit Ort Land" th:text="${user.defaultDeliveryAddress.addressString}"/>
-
+
@@ -100,9 +97,9 @@ Deutschland
- +
- +
@@ -115,7 +112,7 @@ Deutschland
- +