build controller
This commit is contained in:
parent
3814f8d420
commit
5ae07a444e
|
@ -26,234 +26,179 @@ public class RequestController {
|
|||
}
|
||||
|
||||
@GetMapping("/")
|
||||
public String greeting() {
|
||||
return "redirect:/home";
|
||||
}
|
||||
|
||||
@GetMapping("/home")
|
||||
public String home(@CookieValue(value = "loginToken", defaultValue = "") String loginToken, Model model) {
|
||||
if (!loginToken.equals("")) {
|
||||
model.addAttribute(new Customer());
|
||||
}
|
||||
return "home";
|
||||
}
|
||||
|
||||
@GetMapping("/articledetail")
|
||||
public String articledetail() {
|
||||
return "articleDetail";
|
||||
}
|
||||
|
||||
@GetMapping("/searchresults")
|
||||
public String searchresults() {
|
||||
return "searchResults";
|
||||
}
|
||||
|
||||
@GetMapping("/shoppingcart")
|
||||
public String shoppingcart() {
|
||||
return "shoppingCart";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/customerdetail")
|
||||
public String customerdetail() {
|
||||
// TODO @PH
|
||||
return "intern/customer";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/customerorders")
|
||||
public String customerorders() {
|
||||
// TODO @PH
|
||||
return "intern/customerorders";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/accounting")
|
||||
public String accounting() {
|
||||
return "intern/accounting";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/accountingvat")
|
||||
public String accountingvat() {
|
||||
return "intern/accountingvat";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/accountingmain")
|
||||
public String accountingmain() {
|
||||
return "intern/accountingmain";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/accountingmanual")
|
||||
public String accountingmanual() {
|
||||
return "intern/accountingmanual";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/addarticle")
|
||||
public String addarticle() {
|
||||
return "intern/addarticle";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/articles")
|
||||
public String articles() {
|
||||
return "intern/articles";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/listedarticles")
|
||||
public String listedarticles() {
|
||||
return "intern/listedArticles";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/listedarticlesedit")
|
||||
public String listedarticlesedit() {
|
||||
return "intern/listedArticlesEdit";
|
||||
}
|
||||
|
||||
@GetMapping("/notification")
|
||||
public String notification() {
|
||||
return "notification";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/customers_allOrders_overview")
|
||||
public String customers_allOrders_overview() {
|
||||
return "intern/customers_allOrders_overview";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/customers_order_detailview")
|
||||
public String customers_order_detailview() {
|
||||
return "intern/customers_order_detailview";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/customers_overview")
|
||||
public String customers_overview() {
|
||||
return "intern/customers_overview";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/customers_detailview_bookings_orders")
|
||||
public String customers_detailview_bookings_orders() {
|
||||
return "intern/customers_detailview_bookings_orders";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/suppliers_overview")
|
||||
public String suppliers_overview() {
|
||||
return "intern/suppliers_overview";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/suppliers_detailview_bookings_orders")
|
||||
public String suppliers_detailview_bookings_orders() {
|
||||
return "intern/suppliers_detailview_bookings_orders";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/suppliers_allOrders_overview")
|
||||
public String suppliers_allOrders_overview() {
|
||||
return "intern/suppliers_allOrders_overview";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/suppliers_order_detailview")
|
||||
public String suppliers_order_detailview() {
|
||||
return "intern/suppliers_order_detailview";
|
||||
}
|
||||
|
||||
@GetMapping("/customer/accountsettings")
|
||||
public String customerAccountSettings(Model model) {
|
||||
Customer customer = new Customer();
|
||||
customer.setFirstname("Max");
|
||||
customer.setLastname("Mustermann");
|
||||
customer.setUsername("Max.TestKunde");
|
||||
customer.setPassword("test123");
|
||||
model.addAttribute(customer);
|
||||
|
||||
model.addAttribute("fullname", customer.getFirstname() + " " + customer.getLastname());
|
||||
model.addAttribute("email", "Test.User@ecommere.com");
|
||||
|
||||
model.addAttribute("street", "Musterstraße 42a");
|
||||
model.addAttribute("city", "Musterstadt");
|
||||
model.addAttribute("zipcode", "12345");
|
||||
model.addAttribute("country", "Musterland");
|
||||
|
||||
return "/customer/accountSettings";
|
||||
}
|
||||
|
||||
@GetMapping("/customer/orderhistory")
|
||||
public String customerOrderHistory() {
|
||||
return "customer/orderHistory";
|
||||
}
|
||||
|
||||
@GetMapping("/customer/bonusprogram")
|
||||
public String customerBonusProgram() {
|
||||
return "customer/bonusProgram";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/updateAccountSettings", method = RequestMethod.POST, params = "action=updateAccountSettings")
|
||||
public String updateAccountSettings(@ModelAttribute Customer customer, HttpServletResponse response) {
|
||||
// do the login magic and get a loginToken
|
||||
System.out.println(customer.username);
|
||||
System.out.println(customer.password);
|
||||
|
||||
return "/customer/accountsettings";
|
||||
public String home() {
|
||||
return "redirect:/shop/";
|
||||
}
|
||||
|
||||
@GetMapping("/login")
|
||||
public String login(@CookieValue(value = "loginToken", defaultValue = "") String loginToken, Model model) {
|
||||
model.addAttribute(new Customer());
|
||||
|
||||
System.out.println(loginToken); // TODO if cookie is present, redirect to home
|
||||
return "login";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/login", method = RequestMethod.POST, params = "action=login")
|
||||
public String loginAction(@ModelAttribute Customer customer, HttpServletResponse response) {
|
||||
Cookie cookie = new Login(customerRepo).getLoginToken(customer);
|
||||
if (cookie != null) {
|
||||
response.addCookie(cookie);
|
||||
return "redirect:home";
|
||||
} else {
|
||||
return "redirect:login"; // redirect so the input files get cleared, otherwise only pwd gets cleared
|
||||
}
|
||||
public String login() {
|
||||
return "/login";
|
||||
}
|
||||
|
||||
@GetMapping("/register")
|
||||
public String register(@CookieValue(value = "loginToken", defaultValue = "") String loginToken, Model model) {
|
||||
model.addAttribute(new Customer());
|
||||
public String register() {
|
||||
return "/register";
|
||||
}
|
||||
|
||||
System.out.println(loginToken); // TODO if cookie is present, redirect to home
|
||||
return "register";
|
||||
@GetMapping("/shop/")
|
||||
public String shop() {
|
||||
return "/shop/index";
|
||||
}
|
||||
|
||||
@GetMapping("/shop/search")
|
||||
public String shopSearch() {
|
||||
return "/shop/search";
|
||||
}
|
||||
|
||||
@GetMapping("/shop/articles/{id}")
|
||||
public String shopArticlesById() {
|
||||
return "/shop/articles/id";
|
||||
}
|
||||
|
||||
@GetMapping("/user/")
|
||||
public String user() {
|
||||
return "/user/index";
|
||||
}
|
||||
|
||||
@GetMapping("/user/settings")
|
||||
public String userSettings() {
|
||||
return "/user/settings";
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/register", method = RequestMethod.POST, params = "action=register")
|
||||
public String registerAction(@ModelAttribute Customer customer, HttpServletResponse response) {
|
||||
// do the register magic and get a loginToken
|
||||
System.out.println(customer.username);
|
||||
System.out.println(customer.password);
|
||||
@GetMapping("/user/orders/")
|
||||
public String userOrdeers() {
|
||||
return "/user/orders/";
|
||||
}
|
||||
|
||||
if (customerRepo.findByUsername(customer.username).size() != 0) {
|
||||
// TODO
|
||||
System.out.println("The customer exists already");
|
||||
return "redirect:register";
|
||||
} else {
|
||||
customerRepo.save(customer);
|
||||
System.out.println(customerRepo.findByUsername(customer.username).size());
|
||||
}
|
||||
@GetMapping("/user/orders/{id}")
|
||||
public String userOrdersId() {
|
||||
return "/user/orders/id";
|
||||
}
|
||||
|
||||
// return a login token after successful registration
|
||||
String loginToken = UUID.randomUUID().toString();
|
||||
@GetMapping("/user/bonuspoints")
|
||||
public String userBonuspoints() {
|
||||
return "/user/bonuspoints";
|
||||
}
|
||||
|
||||
// set the loginToken as session cookie
|
||||
Cookie cookie = new Cookie("loginToken", loginToken);
|
||||
response.addCookie(cookie);
|
||||
return "home";
|
||||
@GetMapping("/user/notifications/")
|
||||
public String userNotifications() {
|
||||
return "/user/notifications/";
|
||||
}
|
||||
|
||||
@GetMapping("/user/notifications/{id}")
|
||||
public String userNotificationsId() {
|
||||
return "/user/notifications/id";
|
||||
}
|
||||
|
||||
@GetMapping("/about")
|
||||
public String about() {
|
||||
return "about";
|
||||
return "/about";
|
||||
}
|
||||
|
||||
@GetMapping("/terms")
|
||||
public String terms() {
|
||||
return "terms";
|
||||
return "/terms";
|
||||
}
|
||||
|
||||
@GetMapping("/privacy")
|
||||
public String privacy() {
|
||||
return "privacy";
|
||||
return "/privacy";
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/intern/")
|
||||
public String intern() {
|
||||
return "/intern/index";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/listedArticles/")
|
||||
public String internListedArticles() {
|
||||
return "/intern/listedArticles/index";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/listedArticles/{id}")
|
||||
public String internListedArticlesId() {
|
||||
return "/intern/listedArticles/id";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/articles/")
|
||||
public String internArticles() {
|
||||
return "/intern/articles/index";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/articles/{id}")
|
||||
public String internArticlesId() {
|
||||
return "/intern/articles/id";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/customers/")
|
||||
public String internCustomers() {
|
||||
return "/intern/customers/index";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/customers/{id}")
|
||||
public String internCustomersId() {
|
||||
return "/intern/customers/id";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/customerOrders/")
|
||||
public String internCustomerOrder() {
|
||||
return "/intern/customerOrders/index";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/customerOrders/{id}")
|
||||
public String internCustomerOrdersId() {
|
||||
return "/intern/customerOrders/id";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/suppliers/")
|
||||
public String internSuppliers() {
|
||||
return "/intern/suppliers/index";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/suppliers/{id}")
|
||||
public String internSuppliersId() {
|
||||
return "/intern/suppliers/id";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/supplierOrders/")
|
||||
public String internSupplierOrders() {
|
||||
return "/intern/supplierOrders/index";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/supplierOrders/{id}")
|
||||
public String internSupplierOrdersId() {
|
||||
return "/intern/supplierOrders/id";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/accounting/")
|
||||
public String accounting() {
|
||||
return "/intern/accounting/index";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/accounting/vat")
|
||||
public String accountingVat() {
|
||||
return "/intern/accounting/vat";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/accounting/intern")
|
||||
public String accountingIntern() {
|
||||
return "/intern/accounting/intern";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/accounting/addManual")
|
||||
public String accountingAddManual() {
|
||||
return "/intern/accounting/addManual";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/warehouse/")
|
||||
public String accountingWarehouse() {
|
||||
return "/intern/warehouse/";
|
||||
}
|
||||
|
||||
@GetMapping("/intern/warehouse/addManual")
|
||||
public String accountingWarehouseAddManual() {
|
||||
return "/intern/warehouse/addManual";
|
||||
}
|
||||
}
|
||||
|
|
Reference in New Issue