show usersettings from db

This commit is contained in:
Hannes Huber 2020-05-18 14:41:33 +02:00
parent 7c73f69865
commit 106b00a907
4 changed files with 63 additions and 49 deletions

View File

@ -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";
}
}

View File

@ -1,8 +1,55 @@
package org.hso.ecommerce.controller; 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.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 @Controller
//@RequestMapping("...") @RequestMapping("/user")
public class UserController { 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";
// }
} }

View File

@ -24,10 +24,16 @@ public class User {
@Column(unique = true) @Column(unique = true)
public String email; public String email;
@Column(insertable=false, updatable = false)
public String name;
public String salutation;
public String passwordHash; public String passwordHash;
public boolean isActive; public boolean isActive;
public boolean isEmployee; public boolean isEmployee;
public boolean isAdvertisementActivated;
@Embedded @Embedded
public Address defaultDeliveryAddress; public Address defaultDeliveryAddress;

View File

@ -27,7 +27,7 @@
</div> </div>
<div> <div>
<div class="input-icon"> <div class="input-icon">
<input class="full-width" type="text" name="email" value="max.mueller@example.com" required/> <input class="full-width" type="text" name="email" th:value="${user.email}" required/>
<button> Email-Adresse ändern</button> <button> Email-Adresse ändern</button>
</div> </div>
</div> </div>
@ -59,7 +59,7 @@
<div class="col-2"> <div class="col-2">
<div> <div>
<label for="salutation">Anrede</label> <label for="salutation">Anrede</label>
<input class="full-width" list="salutationsOpt" name="salutation" placeholder="Anrede" value="Herr" <input class="full-width" list="salutationsOpt" name="salutation" placeholder="Anrede" th:value="${user.salutation}"
required/> required/>
<datalist id="salutationsOpt"> <datalist id="salutationsOpt">
<option value="Herr"> <option value="Herr">
@ -70,7 +70,7 @@
</div> </div>
<div> <div>
<label for="name">Name</label> <label for="name">Name</label>
<input class="full-width" type="text" name="name" placeholder="Nachname Vorname" value="Max Müller" <input class="full-width" type="text" name="name" placeholder="Nachname Vorname" th:value="${user.name}"
required/> required/>
</div> </div>
</div> </div>
@ -78,17 +78,14 @@
<div> <div>
<label for="address">Anschrift</label> <label for="address">Anschrift</label>
<textarea rows="5" class="full-width" type="text" name="address" <textarea rows="5" class="full-width" type="text" name="address"
placeholder="Optional: Zusatz&#10;Optional: Unternehmen&#10;Straße Hausnummer&#10;Postleitzeit Ort&#10;Land"> placeholder="Optional: Zusatz&#10;Optional: Unternehmen&#10;Straße Hausnummer&#10;Postleitzeit Ort&#10;Land" th:text="${user.defaultDeliveryAddress.addressString}"/>
Musterstraße 26
7158 Mustertal
Deutschland</textarea>
</div> </div>
<fieldset> <!--<fieldset>
<input type="radio" name="type" value="priv" id="type-priv" required checked> <input type="radio" name="type" value="priv" id="type-priv" required checked>
<label for="type-priv">Ich bin Privatkunde.</label> <br/> <label for="type-priv">Ich bin Privatkunde.</label> <br/>
<input type="radio" name="type" value="bus" id="type-bus" required> <input type="radio" name="type" value="bus" id="type-bus" required>
<label for="type-bus">Ich bin Geschäftskunde.</label> <br/> <label for="type-bus">Ich bin Geschäftskunde.</label> <br/>
</fieldset> </fieldset>-->
<div> <div>
<button> Lieferinformation ändern</button> <button> Lieferinformation ändern</button>
</div> </div>
@ -100,9 +97,9 @@ Deutschland</textarea>
</div> </div>
<div> <div>
<fieldset> <fieldset>
<input type="radio" name="ad" value="y" id="ad-y" required checked> <input type="radio" name="ad" value="y" id="ad-y" required th:checked="${user.isAdvertisementActivated}">
<label for="type-priv">Ich möchte Werbung erhalten.</label> <br/> <label for="type-priv">Ich möchte Werbung erhalten.</label> <br/>
<input type="radio" name="ad" value="n" id="ad-n" required> <input type="radio" name="ad" value="n" id="ad-n" required th:checked="${!user.isAdvertisementActivated}">
<label for="type-bus">Ich möchte keine Werbung erhalten.</label> <br/> <label for="type-bus">Ich möchte keine Werbung erhalten.</label> <br/>
</fieldset> </fieldset>
<button type="submit"> Speichern</button> <button type="submit"> Speichern</button>
@ -115,7 +112,7 @@ Deutschland</textarea>
</div> </div>
<div> <div>
<div class="input-icon"> <div class="input-icon">
<input class="full-width" type="text" name="payment-card" placeholder="XXXXXXXX840" required/> <input class="full-width" type="text" name="payment-card" th:value="${user.defaultPayment.creditCardNumber}" required/>
<button> Kreditkartennummer ändern</button> <button> Kreditkartennummer ändern</button>
</div> </div>
</div> </div>