Open nloaveee opened 1 month ago
<찜하기>
비로그인 경우 로그인 하라는 경고창 -> 로그인 페이지로 이동
상품에서 옵션이 color/size로 되어 있어서 아래와 같이 나눠서 배열에 담아서 controller로 보내줌
$('#orderTable tr').each(function() {
let option = $(this).find("td").eq(1).html();
let [color, size] = option.split('/');
$.ajax({
type: "post"
,url: "/shop/user/mypage/wish/add"
,data: {"color":color, "size":size, "itemId":itemId}
하나의 아이템에 옵션이 여러 개인 경우도 있기 때문에 List로 넘겨줘서 optionId를 찾은 다음에 wish 테이블에 저장
public boolean addWish(String userId, String size, String color, int itemId) {
List<ItemOption> optionList = itemBO.getItemOptionByItemIdColorSize(itemId, color, size);
for(ItemOption option:optionList) {
int optionId = option.getId();
wishRepository.save(Wish.builder()
.userId(userId)
.optionId(optionId)
.build());
}
return true;
}
<상품 주문>