64 lines
1.8 KiB
Java
64 lines
1.8 KiB
Java
package org.hso.ecommerce.controller.shop;
|
|
|
|
import org.hso.ecommerce.entities.user.User;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpSession;
|
|
|
|
@Controller
|
|
@RequestMapping("shop")
|
|
public class ShopRequestController {
|
|
|
|
@GetMapping("/")
|
|
public String shop() {
|
|
return "shop/index";
|
|
}
|
|
|
|
@GetMapping("/search")
|
|
public String shopSearch() {
|
|
return "shop/search";
|
|
}
|
|
|
|
@GetMapping("/checkout")
|
|
public String shopCheckout(HttpSession session, HttpServletRequest request) {
|
|
session.setAttribute("afterLogin", request.getRequestURI());
|
|
return "shop/checkout";
|
|
}
|
|
|
|
@PostMapping("/checkoutFinish")
|
|
public String shopCheckoutFinish() {
|
|
return "shop/checkoutFinish";
|
|
}
|
|
|
|
@GetMapping("/checkoutFinish")
|
|
public String shopCheckoutFinishGET() {
|
|
return "shop/checkoutFinish";
|
|
}
|
|
|
|
@GetMapping("/articles/{id}")
|
|
public String shopArticlesById() {
|
|
return "shop/articles/id";
|
|
}
|
|
|
|
@PostMapping("/articles/{id}")
|
|
public String shopArticlesByIdBuy(HttpSession session,
|
|
@RequestAttribute(value = "user", required = false) User customer,
|
|
@PathVariable("id") Integer id,
|
|
@RequestParam("fastcheckout") Boolean fastcheckout
|
|
) {
|
|
if (customer != null) {
|
|
if (!fastcheckout) {
|
|
return "shop/articles/post_add";
|
|
} else {
|
|
return "shop/checkout";
|
|
}
|
|
} else {
|
|
session.setAttribute("afterLogin", "/shop/articles/" + id);
|
|
return "redirect:/login";
|
|
}
|
|
}
|
|
|
|
}
|