show usersettings from db
This commit is contained in:
		@ -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";
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -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";
 | 
			
		||||
//    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -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;
 | 
			
		||||
 | 
			
		||||
@ -27,7 +27,7 @@
 | 
			
		||||
            </div>
 | 
			
		||||
            <div>
 | 
			
		||||
                <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>
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
@ -59,7 +59,7 @@
 | 
			
		||||
            <div class="col-2">
 | 
			
		||||
                <div>
 | 
			
		||||
                    <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/>
 | 
			
		||||
                    <datalist id="salutationsOpt">
 | 
			
		||||
                        <option value="Herr">
 | 
			
		||||
@ -70,7 +70,7 @@
 | 
			
		||||
                </div>
 | 
			
		||||
                <div>
 | 
			
		||||
                    <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/>
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
@ -78,17 +78,14 @@
 | 
			
		||||
            <div>
 | 
			
		||||
                <label for="address">Anschrift</label>
 | 
			
		||||
                <textarea rows="5" class="full-width" type="text" name="address"
 | 
			
		||||
                          placeholder="Optional: Zusatz
Optional: Unternehmen
Straße Hausnummer
Postleitzeit Ort
Land">
 | 
			
		||||
Musterstraße 26
 | 
			
		||||
7158 Mustertal
 | 
			
		||||
Deutschland</textarea>
 | 
			
		||||
                          placeholder="Optional: Zusatz
Optional: Unternehmen
Straße Hausnummer
Postleitzeit Ort
Land" th:text="${user.defaultDeliveryAddress.addressString}"/>
 | 
			
		||||
            </div>
 | 
			
		||||
            <fieldset>
 | 
			
		||||
            <!--<fieldset>
 | 
			
		||||
                <input type="radio" name="type" value="priv" id="type-priv" required checked>
 | 
			
		||||
                <label for="type-priv">Ich bin Privatkunde.</label> <br/>
 | 
			
		||||
                <input type="radio" name="type" value="bus" id="type-bus" required>
 | 
			
		||||
                <label for="type-bus">Ich bin Geschäftskunde.</label> <br/>
 | 
			
		||||
            </fieldset>
 | 
			
		||||
            </fieldset>-->
 | 
			
		||||
            <div>
 | 
			
		||||
                <button> Lieferinformation ändern</button>
 | 
			
		||||
            </div>
 | 
			
		||||
@ -100,9 +97,9 @@ Deutschland</textarea>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div>
 | 
			
		||||
                <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/>
 | 
			
		||||
                    <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/>
 | 
			
		||||
                </fieldset>
 | 
			
		||||
                <button type="submit"> Speichern</button>
 | 
			
		||||
@ -115,7 +112,7 @@ Deutschland</textarea>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div>
 | 
			
		||||
                <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>
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user