Commit b699ae68 authored by keita.onoguchi's avatar keita.onoguchi

カート編集機能追加

parent 3edb25de
......@@ -14,7 +14,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter{
@Override
public void configure(WebSecurity web) throws Exception{
web.debug(false).ignoring().antMatchers("/images/**", "/js/**", "/css/**", "/fonts/**", "/limited/inputCart", "/limited/buy");
web.debug(false).ignoring().antMatchers("/images/**", "/js/**", "/css/**", "/fonts/**", "/limited/inputCart", "/limited/buy", "/limited/editCart");
}
@Override
......
......@@ -115,6 +115,17 @@ public class EcsiteRestController {
}
}
@PostMapping("editCart")
public void editCart(@RequestBody ItemData data, Shoes shoes) {
System.out.println(data.getQuantity());
LinkedHashMap<String, Items> cart = new LinkedHashMap<String, Items>();
String id = data.getShoesId().toString();
//生成したHashMapにセッションにもともとある情報を照会させる。
cart = (LinkedHashMap<String, Items>) session.getAttribute("cart");
cart.put(id , itemsService.findOne(data.getShoesId(),data.getQuantity()));
session.setAttribute("cart", cart);
}
@GetMapping("buy")
public void buy(@AuthenticationPrincipal LoginUser userDetails, LinkedHashMap<String, Items> items, ArrayList <Items> cart, Wallets wallet){
items = (LinkedHashMap<String, Items>) session.getAttribute("cart");
......
......@@ -24,4 +24,30 @@ $('#ok-btn').on('click',function(){
.fail(function(){
alert("ウォレットの残高が足りません。チャージしてください");
})
});
//商品個数追加
$('.itemCountChange').on('click', function(event){
console.log(event.target.parentElement.parentElement.children[0].textContent);
console.log(event.target.parentElement.parentElement.children[3].children[0].value);
let data = {
shoesId: parseInt(event.target.parentElement.parentElement.children[0].textContent),
quantity: parseInt(event.target.parentElement.parentElement.children[3].children[0].value)
};
$.ajax({
type: "POST",
url: "/limited/editCart",
contentType: 'application/json',
dataType: "json",
data: JSON.stringify(data)
})
window.location.href = "/limited/cart";
//[#modal-content]と[#modal-overlay]をフェードアウトした後に…
$( "#modal-content,#modal-overlay" ).fadeOut( "slow" , function(){
//[#modal-overlay]を削除する
$('#modal-overlay').remove() ;
}) ;
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment