code cleanup
This commit is contained in:
parent
c194f44308
commit
5a59ac11b0
|
@ -7,21 +7,24 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import org.hso.ecommerce.controller.intern.accounting.AccountingController;
|
||||
import org.hso.ecommerce.controller.intern.accounting.AccountingController.ShortTemplateBookingResult;
|
||||
import org.hso.ecommerce.entities.booking.Booking;
|
||||
import org.hso.ecommerce.entities.booking.BookingAccountEntry;
|
||||
import org.hso.ecommerce.entities.shop.CustomerOrder;
|
||||
import org.hso.ecommerce.entities.user.User;
|
||||
import org.hso.ecommerce.repos.booking.BookingAccountEntryRepository;
|
||||
import org.hso.ecommerce.repos.booking.BookingRepository;
|
||||
import org.hso.ecommerce.repos.shop.CustomerOrderRepository;
|
||||
import org.hso.ecommerce.repos.user.UserRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.hso.ecommerce.controller.intern.accounting.AccountingController;
|
||||
import org.hso.ecommerce.controller.intern.accounting.AccountingController.ShortTemplateBookingResult;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Controller
|
||||
|
@ -42,9 +45,10 @@ public class CustomersIndexController {
|
|||
|
||||
@GetMapping("")
|
||||
public String internCustomers(Model model) {
|
||||
List<User> users = userRepository.findAll();
|
||||
|
||||
model.addAttribute("users", users);
|
||||
|
||||
@GetMapping("/")
|
||||
public String internCustomers() {
|
||||
return "intern/customers/index";
|
||||
}
|
||||
|
||||
|
@ -55,7 +59,7 @@ public class CustomersIndexController {
|
|||
HttpServletRequest request
|
||||
) {
|
||||
Optional<User> optUser = userRepository.findById(id);
|
||||
if(!optUser.isPresent()){
|
||||
if (!optUser.isPresent()) {
|
||||
request.setAttribute("error", "Der User wurde nicht gefunden.");
|
||||
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
||||
return "error/404";
|
||||
|
@ -79,16 +83,16 @@ public class CustomersIndexController {
|
|||
@PostMapping("/{id}/changeState")
|
||||
public String changeState(@PathVariable("id") Long id,
|
||||
@RequestParam(value = "active", required = false) String active,
|
||||
@RequestParam(value = "ma",required = false) String ma
|
||||
){
|
||||
@RequestParam(value = "ma", required = false) String ma
|
||||
) {
|
||||
User user = userRepository.findById(id).get();
|
||||
|
||||
if(active == null)
|
||||
if (active == null)
|
||||
user.isActive = false;
|
||||
else
|
||||
user.isActive = true;
|
||||
|
||||
if(ma == null)
|
||||
if (ma == null)
|
||||
user.isEmployee = false;
|
||||
else
|
||||
user.isEmployee = true;
|
||||
|
@ -103,13 +107,13 @@ public class CustomersIndexController {
|
|||
@RequestParam("password") String password,
|
||||
@RequestParam("password2") String password2,
|
||||
HttpServletRequest request
|
||||
){
|
||||
if(!password.equals(password2)){
|
||||
) {
|
||||
if (!password.equals(password2)) {
|
||||
request.setAttribute("error", "Passwörter stimmen nicht überein!");
|
||||
return "/intern/customers/id";
|
||||
}
|
||||
User user = userRepository.findById(id).get();
|
||||
if(!user.validatePassword(password)){
|
||||
if (!user.validatePassword(password)) {
|
||||
request.setAttribute("error", "Die Passwörter stimmen nicht mit dem Original überein!");
|
||||
return "/intern/customers/id";
|
||||
}
|
||||
|
|
Reference in New Issue