@@ -56,4 +56,14 @@ public class CartController {
|
||||
return "/cart";
|
||||
}
|
||||
|
||||
/* 장바구니 수량 수정 */
|
||||
@PostMapping("/cart/update")
|
||||
public String updateCartPOST(CartDTO cart) {
|
||||
|
||||
cartService.modifyCount(cart);
|
||||
|
||||
return "redirect:/cart/" + cart.getMemberId();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,5 +11,8 @@ public interface CartService {
|
||||
|
||||
/* 장바구니 정보 리스트 */
|
||||
public List<CartDTO> getCartList(String memberId);
|
||||
|
||||
/* 카트 수량 수정 */
|
||||
public int modifyCount(CartDTO cart);
|
||||
|
||||
}
|
||||
|
||||
@@ -59,5 +59,11 @@ public class CartServiceImpl implements CartService {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int modifyCount(CartDTO cart) {
|
||||
|
||||
return cartMapper.modifyCount(cart);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@
|
||||
<button class="quantity_btn plus_btn">+</button>
|
||||
<button class="quantity_btn minus_btn">-</button>
|
||||
</div>
|
||||
<a class="quantity_modify_btn">변경</a>
|
||||
<a class="quantity_modify_btn" data-cartId="${ci.cartId}">변경</a>
|
||||
</td>
|
||||
<td class="td_width_4 table_text_align_center">
|
||||
<fmt:formatNumber value="${ci.salePrice * ci.bookCount}" pattern="#,### 원" />
|
||||
@@ -235,7 +235,12 @@
|
||||
<a>주문하기</a>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- 수량 조정 form -->
|
||||
<form action="/cart/update" method="post" class="quantity_update_form">
|
||||
<input type="hidden" name="cartId" class="update_cartId">
|
||||
<input type="hidden" name="bookCount" class="update_bookCount">
|
||||
<input type="hidden" name="memberId" value="${member.memberId}">
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -384,6 +389,28 @@ function setTotalInfo(){
|
||||
$(".finalTotalPrice_span").text(finalTotalPrice.toLocaleString());
|
||||
}
|
||||
|
||||
/* 수량버튼 */
|
||||
$(".plus_btn").on("click", function(){
|
||||
let quantity = $(this).parent("div").find("input").val();
|
||||
$(this).parent("div").find("input").val(++quantity);
|
||||
});
|
||||
$(".minus_btn").on("click", function(){
|
||||
let quantity = $(this).parent("div").find("input").val();
|
||||
if(quantity > 1){
|
||||
$(this).parent("div").find("input").val(--quantity);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/* 수량 수정 버튼 */
|
||||
$(".quantity_modify_btn").on("click", function(){
|
||||
let cartId = $(this).data("cartid");
|
||||
let bookCount = $(this).parent("td").find("input").val();
|
||||
$(".update_cartId").val(cartId);
|
||||
$(".update_bookCount").val(bookCount);
|
||||
$(".quantity_update_form").submit();
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -54,6 +54,16 @@ public class CartController {
|
||||
model.addAttribute("cartInfo", cartService.getCartList(memberId));
|
||||
|
||||
return "/cart";
|
||||
}
|
||||
}
|
||||
|
||||
/* 장바구니 수량 수정 */
|
||||
@PostMapping("/cart/update")
|
||||
public String updateCartPOST(CartDTO cart) {
|
||||
|
||||
cartService.modifyCount(cart);
|
||||
|
||||
return "redirect:/cart/" + cart.getMemberId();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@ public interface CartService {
|
||||
public int addCart(CartDTO cart);
|
||||
|
||||
/* 장바구니 정보 리스트 */
|
||||
public List<CartDTO> getCartList(String memberId);
|
||||
public List<CartDTO> getCartList(String memberId);
|
||||
|
||||
/* 카트 수량 수정 */
|
||||
public int modifyCount(CartDTO cart);
|
||||
|
||||
}
|
||||
|
||||
@@ -59,4 +59,10 @@ public class CartServiceImpl implements CartService {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int modifyCount(CartDTO cart) {
|
||||
|
||||
return cartMapper.modifyCount(cart);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@
|
||||
<button class="quantity_btn plus_btn">+</button>
|
||||
<button class="quantity_btn minus_btn">-</button>
|
||||
</div>
|
||||
<a class="quantity_modify_btn">변경</a>
|
||||
<a class="quantity_modify_btn" data-cartId="${ci.cartId}">변경</a>
|
||||
</td>
|
||||
<td class="td_width_4 table_text_align_center">
|
||||
<fmt:formatNumber value="${ci.salePrice * ci.bookCount}" pattern="#,### 원" />
|
||||
@@ -235,7 +235,12 @@
|
||||
<a>주문하기</a>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- 수량 조정 form -->
|
||||
<form action="/cart/update" method="post" class="quantity_update_form">
|
||||
<input type="hidden" name="cartId" class="update_cartId">
|
||||
<input type="hidden" name="bookCount" class="update_bookCount">
|
||||
<input type="hidden" name="memberId" value="${member.memberId}">
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -384,6 +389,28 @@ function setTotalInfo(){
|
||||
$(".finalTotalPrice_span").text(finalTotalPrice.toLocaleString());
|
||||
}
|
||||
|
||||
/* 수량버튼 */
|
||||
$(".plus_btn").on("click", function(){
|
||||
let quantity = $(this).parent("div").find("input").val();
|
||||
$(this).parent("div").find("input").val(++quantity);
|
||||
});
|
||||
$(".minus_btn").on("click", function(){
|
||||
let quantity = $(this).parent("div").find("input").val();
|
||||
if(quantity > 1){
|
||||
$(this).parent("div").find("input").val(--quantity);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/* 수량 수정 버튼 */
|
||||
$(".quantity_modify_btn").on("click", function(){
|
||||
let cartId = $(this).data("cartid");
|
||||
let bookCount = $(this).parent("td").find("input").val();
|
||||
$(".update_cartId").val(cartId);
|
||||
$(".update_bookCount").val(bookCount);
|
||||
$(".quantity_update_form").submit();
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user