From 446aa0fe3b2d094ba968300b66c95c33080b575f Mon Sep 17 00:00:00 2001 From: SeoJin Kim Date: Mon, 29 Nov 2021 19:11:35 +0900 Subject: [PATCH] =?UTF-8?q?[Spring][=EC=87=BC=ED=95=91=EB=AA=B0=20?= =?UTF-8?q?=ED=94=84=EB=A1=9C=EC=A0=9D=ED=8A=B8][37]=20=EC=9E=A5=EB=B0=94?= =?UTF-8?q?=EA=B5=AC=EB=8B=88=20=EA=B8=B0=EB=8A=A5(=EC=9E=A5=EB=B0=94?= =?UTF-8?q?=EA=B5=AC=EB=8B=88=20=ED=8E=98=EC=9D=B4=EC=A7=80)=20-4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://kimvampa.tistory.com/268 --- .../src/main/java/com/vam/model/CartDTO.java | 20 +++++++++++--- .../java/com/vam/service/CartServiceImpl.java | 14 ++++++++++ VamPa/src/main/webapp/WEB-INF/views/cart.jsp | 26 ++++++++++++++++++- VamPa/src/main/webapp/resources/css/cart.css | 10 +++++++ .../src/main/java/com/vam/model/CartDTO.java | 22 +++++++++++++--- .../java/com/vam/service/CartServiceImpl.java | 14 ++++++++++ .../src/main/webapp/WEB-INF/views/cart.jsp | 26 ++++++++++++++++++- .../src/main/webapp/resources/css/cart.css | 10 +++++++ 8 files changed, 133 insertions(+), 9 deletions(-) diff --git a/VamPa/src/main/java/com/vam/model/CartDTO.java b/VamPa/src/main/java/com/vam/model/CartDTO.java index 0f506e8..5e5326e 100644 --- a/VamPa/src/main/java/com/vam/model/CartDTO.java +++ b/VamPa/src/main/java/com/vam/model/CartDTO.java @@ -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 imageList; + public int getCartId() { return cartId; @@ -98,6 +104,14 @@ public class CartDTO { public int getTotalPoint() { return totalPoint; } + + public List getImageList() { + return imageList; + } + + public void setImageList(List 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 + "]"; + } diff --git a/VamPa/src/main/java/com/vam/service/CartServiceImpl.java b/VamPa/src/main/java/com/vam/service/CartServiceImpl.java index 19f3418..aed2d82 100644 --- a/VamPa/src/main/java/com/vam/service/CartServiceImpl.java +++ b/VamPa/src/main/java/com/vam/service/CartServiceImpl.java @@ -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 cart = cartMapper.getCart(memberId); for(CartDTO dto : cart) { + + /* 종합 정보 초기화 */ dto.initSaleTotal(); + + /* 이미지 정보 얻기 */ + int bookId = dto.getBookId(); + + List imageList = attachMapper.getAttachList(bookId); + + dto.setImageList(imageList); } return cart; diff --git a/VamPa/src/main/webapp/WEB-INF/views/cart.jsp b/VamPa/src/main/webapp/WEB-INF/views/cart.jsp index c7e1c73..93a1c03 100644 --- a/VamPa/src/main/webapp/WEB-INF/views/cart.jsp +++ b/VamPa/src/main/webapp/WEB-INF/views/cart.jsp @@ -129,7 +129,11 @@ - + +
+ +
+ ${ci.bookName} 정가 :
@@ -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'); + } + + }); + + }); /* 체크여부에따른 종합 정보 변화 */ diff --git a/VamPa/src/main/webapp/resources/css/cart.css b/VamPa/src/main/webapp/resources/css/cart.css index dd1e85c..b3c9b2f 100644 --- a/VamPa/src/main/webapp/resources/css/cart.css +++ b/VamPa/src/main/webapp/resources/css/cart.css @@ -330,6 +330,16 @@ a{ font-weight: bold; } + /* 이미지 */ + .image_wrap{ + width: 100%; + height: 100%; + } + .image_wrap img{ + max-width: 85%; + height: auto; + display: block; + } /* 로그인 성공 영역 */ diff --git a/VamPa_MySQL/src/main/java/com/vam/model/CartDTO.java b/VamPa_MySQL/src/main/java/com/vam/model/CartDTO.java index 11fbf54..4066de5 100644 --- a/VamPa_MySQL/src/main/java/com/vam/model/CartDTO.java +++ b/VamPa_MySQL/src/main/java/com/vam/model/CartDTO.java @@ -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 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 getImageList() { + return imageList; + } + + public void setImageList(List 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 + "]"; + } } diff --git a/VamPa_MySQL/src/main/java/com/vam/service/CartServiceImpl.java b/VamPa_MySQL/src/main/java/com/vam/service/CartServiceImpl.java index 464d98c..c07f5a9 100644 --- a/VamPa_MySQL/src/main/java/com/vam/service/CartServiceImpl.java +++ b/VamPa_MySQL/src/main/java/com/vam/service/CartServiceImpl.java @@ -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 cart = cartMapper.getCart(memberId); for(CartDTO dto : cart) { + + /* 종합 정보 초기화 */ dto.initSaleTotal(); + + /* 이미지 정보 얻기 */ + int bookId = dto.getBookId(); + + List imageList = attachMapper.getAttachList(bookId); + + dto.setImageList(imageList); } return cart; diff --git a/VamPa_MySQL/src/main/webapp/WEB-INF/views/cart.jsp b/VamPa_MySQL/src/main/webapp/WEB-INF/views/cart.jsp index c7e1c73..93a1c03 100644 --- a/VamPa_MySQL/src/main/webapp/WEB-INF/views/cart.jsp +++ b/VamPa_MySQL/src/main/webapp/WEB-INF/views/cart.jsp @@ -129,7 +129,11 @@ - + +
+ +
+ ${ci.bookName} 정가 :
@@ -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'); + } + + }); + + }); /* 체크여부에따른 종합 정보 변화 */ diff --git a/VamPa_MySQL/src/main/webapp/resources/css/cart.css b/VamPa_MySQL/src/main/webapp/resources/css/cart.css index dd1e85c..b3c9b2f 100644 --- a/VamPa_MySQL/src/main/webapp/resources/css/cart.css +++ b/VamPa_MySQL/src/main/webapp/resources/css/cart.css @@ -330,6 +330,16 @@ a{ font-weight: bold; } + /* 이미지 */ + .image_wrap{ + width: 100%; + height: 100%; + } + .image_wrap img{ + max-width: 85%; + height: auto; + display: block; + } /* 로그인 성공 영역 */