Cookie
Save Cookie
String add(HttpServletResponse res){
token = Helper.randomString(32);
Cookie cookie = new Cookie("token", token);
cookie.setMaxAge(60 * 60 * 24 * 30);
res.addCookie(cookie);
return "home/add";
}
Read Cookie
String index(@CookieValue(name = "token", defaultValue = "") String token){
return "home/index";
}
Cart
public interface CartRepository extends CrudRepository<Cart, Integer> {
@Modifying
@Procedure
void saveCart(String cartCode, long productId, short quantity);
@Transactional
@Modifying
@Query(value = "UPDATE Cart SET Quantity = :quantity WHERE CartId = :id", nativeQuery = true)
void edit(int id, short quantity);
}