[Spring][쇼핑몰 프로젝트][37] 장바구니 기능(장바구니 페이지) -4
https://kimvampa.tistory.com/268
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.vam.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CartDTO {
|
||||
|
||||
private int cartId;
|
||||
@@ -25,7 +27,11 @@ public class CartDTO {
|
||||
|
||||
private int point;
|
||||
|
||||
private int totalPoint;
|
||||
private int totalPoint;
|
||||
|
||||
/* 상품 이미지 */
|
||||
private List<AttachImageVO> imageList;
|
||||
|
||||
|
||||
public int getCartId() {
|
||||
return cartId;
|
||||
@@ -98,6 +104,14 @@ public class CartDTO {
|
||||
public int getTotalPoint() {
|
||||
return totalPoint;
|
||||
}
|
||||
|
||||
public List<AttachImageVO> getImageList() {
|
||||
return imageList;
|
||||
}
|
||||
|
||||
public void setImageList(List<AttachImageVO> imageList) {
|
||||
this.imageList = imageList;
|
||||
}
|
||||
|
||||
public void initSaleTotal() {
|
||||
this.salePrice = (int) (this.bookPrice * (1-this.bookDiscount));
|
||||
@@ -111,8 +125,8 @@ public class CartDTO {
|
||||
return "CartDTO [cartId=" + cartId + ", memberId=" + memberId + ", bookId=" + bookId + ", bookCount="
|
||||
+ bookCount + ", bookName=" + bookName + ", bookPrice=" + bookPrice + ", bookDiscount=" + bookDiscount
|
||||
+ ", salePrice=" + salePrice + ", totalPrice=" + totalPrice + ", point=" + point + ", totalPoint="
|
||||
+ totalPoint + "]";
|
||||
}
|
||||
+ totalPoint + ", imageList=" + imageList + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,13 +5,18 @@ import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.vam.mapper.AttachMapper;
|
||||
import com.vam.mapper.CartMapper;
|
||||
import com.vam.model.AttachImageVO;
|
||||
import com.vam.model.CartDTO;
|
||||
@Service
|
||||
public class CartServiceImpl implements CartService {
|
||||
|
||||
@Autowired
|
||||
private CartMapper cartMapper;
|
||||
|
||||
@Autowired
|
||||
private AttachMapper attachMapper;
|
||||
|
||||
@Override
|
||||
public int addCart(CartDTO cart) {
|
||||
@@ -38,7 +43,16 @@ public class CartServiceImpl implements CartService {
|
||||
List<CartDTO> cart = cartMapper.getCart(memberId);
|
||||
|
||||
for(CartDTO dto : cart) {
|
||||
|
||||
/* 종합 정보 초기화 */
|
||||
dto.initSaleTotal();
|
||||
|
||||
/* 이미지 정보 얻기 */
|
||||
int bookId = dto.getBookId();
|
||||
|
||||
List<AttachImageVO> imageList = attachMapper.getAttachList(bookId);
|
||||
|
||||
dto.setImageList(imageList);
|
||||
}
|
||||
|
||||
return cart;
|
||||
|
||||
@@ -129,7 +129,11 @@
|
||||
<input type="hidden" class="individual_point_input" value="${ci.point}">
|
||||
<input type="hidden" class="individual_totalPoint_input" value="${ci.totalPoint}">
|
||||
</td>
|
||||
<td class="td_width_2"></td>
|
||||
<td class="td_width_2">
|
||||
<div class="image_wrap" data-bookid="${ci.imageList[0].bookId}" data-path="${ci.imageList[0].uploadPath}" data-uuid="${ci.imageList[0].uuid}" data-filename="${ci.imageList[0].fileName}">
|
||||
<img>
|
||||
</div>
|
||||
</td>
|
||||
<td class="td_width_3">${ci.bookName}</td>
|
||||
<td class="td_width_4 price_td">
|
||||
<del>정가 : <fmt:formatNumber value="${ci.bookPrice}" pattern="#,### 원" /></del><br>
|
||||
@@ -282,6 +286,26 @@ $(document).ready(function(){
|
||||
/* 종합 정보 섹션 정보 삽입 */
|
||||
setTotalInfo();
|
||||
|
||||
/* 이미지 삽입 */
|
||||
$(".image_wrap").each(function(i, obj){
|
||||
|
||||
const bobj = $(obj);
|
||||
|
||||
if(bobj.data("bookid")){
|
||||
const uploadPath = bobj.data("path");
|
||||
const uuid = bobj.data("uuid");
|
||||
const fileName = bobj.data("filename");
|
||||
|
||||
const fileCallPath = encodeURIComponent(uploadPath + "/s_" + uuid + "_" + fileName);
|
||||
|
||||
$(this).find("img").attr('src', '/display?fileName=' + fileCallPath);
|
||||
} else {
|
||||
$(this).find("img").attr('src', '/resources/img/goodsNoImage.png');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
/* 체크여부에따른 종합 정보 변화 */
|
||||
|
||||
@@ -330,6 +330,16 @@ a{
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* 이미지 */
|
||||
.image_wrap{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.image_wrap img{
|
||||
max-width: 85%;
|
||||
height: auto;
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
/* 로그인 성공 영역 */
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.vam.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CartDTO {
|
||||
|
||||
private int cartId;
|
||||
@@ -25,7 +27,11 @@ public class CartDTO {
|
||||
|
||||
private int point;
|
||||
|
||||
private int totalPoint;
|
||||
private int totalPoint;
|
||||
|
||||
/* 상품 이미지 */
|
||||
private List<AttachImageVO> imageList;
|
||||
|
||||
|
||||
public int getCartId() {
|
||||
return cartId;
|
||||
@@ -89,7 +95,7 @@ public class CartDTO {
|
||||
|
||||
public int getTotalPrice() {
|
||||
return totalPrice;
|
||||
}
|
||||
}
|
||||
|
||||
public int getPoint() {
|
||||
return point;
|
||||
@@ -98,6 +104,14 @@ public class CartDTO {
|
||||
public int getTotalPoint() {
|
||||
return totalPoint;
|
||||
}
|
||||
|
||||
public List<AttachImageVO> getImageList() {
|
||||
return imageList;
|
||||
}
|
||||
|
||||
public void setImageList(List<AttachImageVO> imageList) {
|
||||
this.imageList = imageList;
|
||||
}
|
||||
|
||||
public void initSaleTotal() {
|
||||
this.salePrice = (int) (this.bookPrice * (1-this.bookDiscount));
|
||||
@@ -111,7 +125,7 @@ public class CartDTO {
|
||||
return "CartDTO [cartId=" + cartId + ", memberId=" + memberId + ", bookId=" + bookId + ", bookCount="
|
||||
+ bookCount + ", bookName=" + bookName + ", bookPrice=" + bookPrice + ", bookDiscount=" + bookDiscount
|
||||
+ ", salePrice=" + salePrice + ", totalPrice=" + totalPrice + ", point=" + point + ", totalPoint="
|
||||
+ totalPoint + "]";
|
||||
}
|
||||
+ totalPoint + ", imageList=" + imageList + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,13 +5,18 @@ import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.vam.mapper.AttachMapper;
|
||||
import com.vam.mapper.CartMapper;
|
||||
import com.vam.model.AttachImageVO;
|
||||
import com.vam.model.CartDTO;
|
||||
@Service
|
||||
public class CartServiceImpl implements CartService {
|
||||
|
||||
@Autowired
|
||||
private CartMapper cartMapper;
|
||||
|
||||
@Autowired
|
||||
private AttachMapper attachMapper;
|
||||
|
||||
@Override
|
||||
public int addCart(CartDTO cart) {
|
||||
@@ -38,7 +43,16 @@ public class CartServiceImpl implements CartService {
|
||||
List<CartDTO> cart = cartMapper.getCart(memberId);
|
||||
|
||||
for(CartDTO dto : cart) {
|
||||
|
||||
/* 종합 정보 초기화 */
|
||||
dto.initSaleTotal();
|
||||
|
||||
/* 이미지 정보 얻기 */
|
||||
int bookId = dto.getBookId();
|
||||
|
||||
List<AttachImageVO> imageList = attachMapper.getAttachList(bookId);
|
||||
|
||||
dto.setImageList(imageList);
|
||||
}
|
||||
|
||||
return cart;
|
||||
|
||||
@@ -129,7 +129,11 @@
|
||||
<input type="hidden" class="individual_point_input" value="${ci.point}">
|
||||
<input type="hidden" class="individual_totalPoint_input" value="${ci.totalPoint}">
|
||||
</td>
|
||||
<td class="td_width_2"></td>
|
||||
<td class="td_width_2">
|
||||
<div class="image_wrap" data-bookid="${ci.imageList[0].bookId}" data-path="${ci.imageList[0].uploadPath}" data-uuid="${ci.imageList[0].uuid}" data-filename="${ci.imageList[0].fileName}">
|
||||
<img>
|
||||
</div>
|
||||
</td>
|
||||
<td class="td_width_3">${ci.bookName}</td>
|
||||
<td class="td_width_4 price_td">
|
||||
<del>정가 : <fmt:formatNumber value="${ci.bookPrice}" pattern="#,### 원" /></del><br>
|
||||
@@ -282,6 +286,26 @@ $(document).ready(function(){
|
||||
/* 종합 정보 섹션 정보 삽입 */
|
||||
setTotalInfo();
|
||||
|
||||
/* 이미지 삽입 */
|
||||
$(".image_wrap").each(function(i, obj){
|
||||
|
||||
const bobj = $(obj);
|
||||
|
||||
if(bobj.data("bookid")){
|
||||
const uploadPath = bobj.data("path");
|
||||
const uuid = bobj.data("uuid");
|
||||
const fileName = bobj.data("filename");
|
||||
|
||||
const fileCallPath = encodeURIComponent(uploadPath + "/s_" + uuid + "_" + fileName);
|
||||
|
||||
$(this).find("img").attr('src', '/display?fileName=' + fileCallPath);
|
||||
} else {
|
||||
$(this).find("img").attr('src', '/resources/img/goodsNoImage.png');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
/* 체크여부에따른 종합 정보 변화 */
|
||||
|
||||
@@ -330,6 +330,16 @@ a{
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* 이미지 */
|
||||
.image_wrap{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.image_wrap img{
|
||||
max-width: 85%;
|
||||
height: auto;
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
/* 로그인 성공 영역 */
|
||||
|
||||
Reference in New Issue
Block a user