diff --git a/VamPa/src/main/java/com/vam/mapper/CartMapper.java b/VamPa/src/main/java/com/vam/mapper/CartMapper.java new file mode 100644 index 0000000..0f45c77 --- /dev/null +++ b/VamPa/src/main/java/com/vam/mapper/CartMapper.java @@ -0,0 +1,24 @@ +package com.vam.mapper; + +import java.util.List; + +import com.vam.model.CartDTO; + +public interface CartMapper { + + /* 카트 추가 */ + public int addCart(CartDTO cart); + + /* 카트 삭제 */ + public int deleteCart(int cartId); + + /* 카트 수량 수정 */ + public int modifyCount(CartDTO cart); + + /* 카트 목록 */ + public List getCart(String memberId); + + /* 카트 확인 */ + public CartDTO checkCart(CartDTO cart); + +} diff --git a/VamPa/src/main/java/com/vam/model/CartDTO.java b/VamPa/src/main/java/com/vam/model/CartDTO.java new file mode 100644 index 0000000..ab99770 --- /dev/null +++ b/VamPa/src/main/java/com/vam/model/CartDTO.java @@ -0,0 +1,105 @@ +package com.vam.model; + +public class CartDTO { + + private int cartId; + + private String memberId; + + private int bookId; + + private int bookCount; + + //book + + private String bookName; + + private int bookPrice; + + private double bookDiscount; + + // 추가 + private int salePrice; + + private int totalPrice; + + public int getCartId() { + return cartId; + } + + public void setCartId(int cartId) { + this.cartId = cartId; + } + + public String getMemberId() { + return memberId; + } + + public void setMemberId(String memberId) { + this.memberId = memberId; + } + + public int getBookId() { + return bookId; + } + + public void setBookId(int bookId) { + this.bookId = bookId; + } + + public int getBookCount() { + return bookCount; + } + + public void setBookCount(int bookCount) { + this.bookCount = bookCount; + } + + public String getBookName() { + return bookName; + } + + public void setBookName(String bookName) { + this.bookName = bookName; + } + + public int getBookPrice() { + return bookPrice; + } + + public void setBookPrice(int bookPrice) { + this.bookPrice = bookPrice; + } + + public double getBookDiscount() { + return bookDiscount; + } + + public void setBookDiscount(double bookDiscount) { + this.bookDiscount = bookDiscount; + } + + public int getSalePrice() { + return salePrice; + } + + public int getTotalPrice() { + return totalPrice; + } + + public void initSaleTotal() { + this.salePrice = (int) (this.bookPrice * (1-this.bookDiscount)); + this.totalPrice = this.salePrice*this.bookCount; + } + + @Override + public String toString() { + return "CartDTO [cartId=" + cartId + ", memberId=" + memberId + ", bookId=" + bookId + ", bookCount=" + + bookCount + ", bookName=" + bookName + ", bookPrice=" + bookPrice + ", bookDiscount=" + bookDiscount + + ", salePrice=" + salePrice + ", totalPrice=" + totalPrice + "]"; + } + + + +} + diff --git a/VamPa/src/main/resources/com/vam/mapper/CartMapper.xml b/VamPa/src/main/resources/com/vam/mapper/CartMapper.xml new file mode 100644 index 0000000..664f5bf --- /dev/null +++ b/VamPa/src/main/resources/com/vam/mapper/CartMapper.xml @@ -0,0 +1,49 @@ + + + + + + + + insert into vam_cart(memberId, bookId, bookCount) + values(#{memberId}, #{bookId}, #{bookCount}) + + + + + + + + delete from vam_cart where cartId = #{cartId} + + + + + + + update vam_cart set bookCount=#{bookCount} where cartId = #{cartId} + + + + + + + + + + + + \ No newline at end of file diff --git a/VamPa/src/main/webapp/WEB-INF/views/goodsDetail.jsp b/VamPa/src/main/webapp/WEB-INF/views/goodsDetail.jsp new file mode 100644 index 0000000..140a2c9 --- /dev/null +++ b/VamPa/src/main/webapp/WEB-INF/views/goodsDetail.jsp @@ -0,0 +1,238 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> + + + + +Welcome BookMall + + + + + +
+
+
+ +
+
+ +
+ +
+
+
+
+
+ + "> + +
+
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+

+ ${goodsInfo.bookName} +

+
+
+
+
+ + ${goodsInfo.authorName} 지음 + + | + + ${goodsInfo.publisher} + + | + + ${goodsInfo.publeYear} + +
+
+
+
+
정가 :
+
+ 판매가 : + [% + 할인]
+
+
+
+
+
+ 주문수량 + + + + + +
+ +
+
+
+
+
+
+
+ ${goodsInfo.bookIntro} +
+
+ ${goodsInfo.bookContents } +
+
+
+
+
+ 리뷰 +
+ +
+ + + + + + +
+
+ + + + + \ No newline at end of file diff --git a/VamPa/src/main/webapp/WEB-INF/views/search.jsp b/VamPa/src/main/webapp/WEB-INF/views/search.jsp index 39629c7..f51004f 100644 --- a/VamPa/src/main/webapp/WEB-INF/views/search.jsp +++ b/VamPa/src/main/webapp/WEB-INF/views/search.jsp @@ -142,7 +142,9 @@ [${list.cateName}]
- ${list.bookName} + + ${list.bookName} +
diff --git a/VamPa/src/main/webapp/resources/css/goodsDetail.css b/VamPa/src/main/webapp/resources/css/goodsDetail.css new file mode 100644 index 0000000..f1d1b2c --- /dev/null +++ b/VamPa/src/main/webapp/resources/css/goodsDetail.css @@ -0,0 +1,423 @@ +@charset "UTF-8"; +*{ + margin: 0; + padding:0; +} +a{ + text-decoration: none; +} +/* 화면 전체 렙 */ +.wrapper{ + width: 100%; +} +/* content 랩 */ +.wrap{ + width : 1080px; + margin: auto; +} +/* 홈페이지 기능 네비 */ +.top_gnb_area{ + width: 100%; + height: 50px; + background-color: #f0f0f1; + position:relative; +} +.top_gnb_area .list{ + position: absolute; + top: 0px; + right: 0; + +} +.top_gnb_area .list li{ + list-style: none; + float : left; + padding: 13px 15px 0 10px; + font-weight: 900; + cursor: pointer; +} +/* 로고, 검색, 로그인 */ +.top_area{ + width: 100%; + height: 150px; + /* background-color: #f7f0b9; */ +} +/* 로고 영역 */ +.logo_area{ + width: 25%; + height: 100%; + float:left; +} +.logo_area img{ + width: 100%; + height: 100%; +} + +/* 검색 박스 영역 */ +.search_area{ + width: 50%; + height: 100%; + float:left; +} +.search_wrap{ + width: 100%; + height: 100%; +} +#searchForm{ + width: 100%; + height: 100%; + display: flex; + justify-content: center; + align-items: center; +} +.search_input{ + display: flex; + height: 30%; + width: 80%; +} +.search_input select{ + width: 20%; + text-align: center; + font-size: 15px; +} +.search_input input{ + margin-left: 10px; + width: 57%; + font-size: 18px; + padding-left: 2%; +} +.search_btn{ + margin-left: 10px; + width: 17%; + border-radius: 14px; + font-size: 17px; + font-weight: 600; +} + + +/* 로그인 버튼 영역 */ +.login_area{ + width: 25%; + height: 100%; + display: inline-block; + text-align: center; +} +.login_button{ + height: 50%; + background-color: #D4DFE6; + margin-top: 30px; + line-height: 77px; + font-size: 40px; + font-weight: 900; + border-radius: 10px; + cursor: pointer; +} +.login_area>span{ + margin-top: 10px; + font-weight: 900; + display: inline-block; +} +.login_button{ + height : 50%; + background-color: #D4DFE6; + margin-top:30px; +} + +/* 제품 목록 네비 */ +.navi_bar_area{ + width: 100%; + height: 70px; + background-color: #7696fd; +} + +/* 홈페이지 메인 제품 목록 */ +.content_area{ + width: 100%; + min-height: 1000px; +} + .content_top{ + width: 100%; + height: 400px; + } + .content_top:after { + content: ""; + clear: both; + display: table; + } + .ct_left_area{ + float: left; + width: 30%; + height: 100%; + } + .image_wrap{ + height: 80%; + width: 80%; + margin: auto; + top: 10%; + position: relative; + } + .image_wrap img{ + max-width: 100%; + height: auto; + display: block; + } + .line{ + width: 100%; + border-top:1px solid #c6c6cf; + } + + + + .ct_right_area{ + float: left; + width: 70%; + height: 100%; + } + .title{ + height: 28%; + font-size: 17px; + line-height: 110px; + color: #3a60df; + padding-left: 3%; + } + .author{ + font-size: 16px; + line-height: 50px; + padding-left: 3%; + } + .price{ + line-height: 30px; + padding: 2% 0 2% 3%; + } + .discount_price_number{ + line-height: 30px; + font-size: 22px; + color: #f84450; + font-weight: bold; + } + .button{ + padding: 2% 0 2% 3%; + } + .button_quantity{ + margin-bottom: 2%; + + } + .button_quantity input{ + height: 26px; + width: 40px; + text-align: center; + font-weight: bold; + } + .button_quantity button{ + border: 1px solid #aaa; + color: #3a60df; + width: 20px; + height: 20px; + padding: 3px; + background-color: #fff; + font-weight: bold; + font-size: 15px; + line-height: 15px; + } + .btn_cart{ + display: inline-block; + width: 140px; + text-align: center; + height: 50px; + line-height: 50px; + background-color: #5e6b9f; + border: 1px solid #5e6b9f; + color: #fff; + margin-right: 2px; + } + .btn_buy{ + display: inline-block; + width: 140px; + text-align: center; + height: 50px; + line-height: 50px; + background-color: #7b8ed1; + border: 1px solid #7b8ed1; + color: #fff; + } + + .content_middle{ + width: 100%; + min-height: 600px; + } + + .book_intro{ + width: 80%; + margin: auto; + margin-top: 40px; + } + .book_content{ + width: 80%; + margin: auto; + margin-top: 40px; + margin-bottom: 40px; + } + + .content_bottom{ + width: 100%; + min-height: 400px; + background-color: #e7dbdb; + } + + + + + +/* 로그인 성공 영역 */ +.login_success_area{ + height: 62%; + width: 80%; + border: 2px solid #7474ad; + border-radius: 15px; + margin: 5% auto; + padding-top: 5%; +} +.login_success_area>a{ + font-size: 15px; + font-weight: 900; + display: inline-block; + margin-top: 5px; + background: #e1e5e8; + width: 82px; + height: 22px; + line-height: 22px; + border-radius: 25px; + color: #606267; +} +.login_success_area>span{ + display : block; + text-align: left; + margin-left: 10%; +} + +/* 검색결과 없음 */ +.table_empty{ + height: 50px; + text-align: center; + margin: 200px 0 215px 0px; + font-size: 25px; +} + +/* 필터정보 */ +.search_filter { + width: 85%; + margin: auto; + margin-top: 30px; + margin-bottom: 50px; +} +.filter_button_wrap { + width: 100%; +} + +.filter_button_wrap button { + width: 50%; +} +.filter_button{ + background-color: #04AA6D; + border: 1px solid green; + color: white; + padding: 10px 24px; + cursor: pointer; + float: left; +} +.filter_button_wrap:after { + content: ""; + clear: both; + display: table; +} +.filter_button_wrap button:not(:last-child) { + border-right: none; +} +.filter_button:hover { + background-color: #3e8e41; +} +.filter_active{ + background-color: #045d3c; +} +.filter_content{ + padding:20px 50px 20px 50px; + border: 1px solid gray; +} +.filter_content a:not(:first-child){ + margin-left: 10px; +} +.filter_a{ + display: block; +} + +.filter_b{ + display: none; +} + + + +/* footer navai 영역 */ +.footer_nav{ + width:100%; + height:50px; +} +.footer_nav_container{ + width: 100%; + height: 100%; + background-color:#8EC0E4; +} +.footer_nav_container>ul{ + font-weight : bold; + float:left; + list-style:none; + position:relative; + padding-top:10px; + line-height: 27px; + font-family: dotum; + margin-left: 10px; +} +.footer_nav_container>ul>li{ + display:inline; + width: 45px; + height: 19px; + padding: 10px 9px 0 10px; +} +.footer_nav_container>ul>span{ + margin: 0 4px; +} +/* footer 영역 */ +.footer{ + width:100%; + height:130px; + background-color:#D4DFE6; + padding-bottom : 50px; +} +.footer_container{ + width: 100%; + height: 100%; + margin: auto; +} +.footer_left>img { + width: 150%; + height: 130px; + margin-left: -20px; + margin-top: -12px; +} +.footer_left{ + float :left; + width: 170px; + margin-left: 20px; + margin-top : 30px; + +} +.footer_right{ + float :left; + width: 680px; + margin-left: 70px; + margin-top : 30px; +} + + +/* float 속성 해제 */ +.clearfix{ + clear: both; +} \ No newline at end of file diff --git a/VamPa/src/test/java/com/vam/mapper/CartMapperTests.java b/VamPa/src/test/java/com/vam/mapper/CartMapperTests.java new file mode 100644 index 0000000..4fdb692 --- /dev/null +++ b/VamPa/src/test/java/com/vam/mapper/CartMapperTests.java @@ -0,0 +1,107 @@ +package com.vam.mapper; + +import java.util.List; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import com.vam.model.CartDTO; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration("file:src/main/webapp/WEB-INF/spring/root-context.xml") +public class CartMapperTests { + + @Autowired + private CartMapper mapper; + + /*카트 등록*/ + /* + @Test + public void addCart() { + String memberId = "admin"; + int bookId = 65; + int count = 2; + + CartDTO cart = new CartDTO(); + cart.setMemberId(memberId); + cart.setBookId(bookId); + cart.setBookCount(count); + + int result = 0; + try { + result = mapper.addCart(cart); + } catch (Exception e) { + System.out.println("에러 발생"); + } + + System.out.println("결과 : " + result); + + } + */ + + /* 카트 삭제 */ + /* + @Test + public void deleteCartTest() { + int cartId = 1; + + mapper.deleteCart(cartId); + } + */ + + /* 카트 수량 수정 */ + /* + @Test + public void modifyCartTest() { + int cartId = 3; + int count = 5; + + CartDTO cart = new CartDTO(); + cart.setCartId(cartId); + cart.setBookCount(count); + + mapper.modifyCount(cart); + + } + */ + + /* + @Test + public void getCartTest() { + String memberId = "admin"; + + + List list = mapper.getCart(memberId); + for(CartDTO cart : list) { + System.out.println(cart); + cart.initSaleTotal(); + System.out.println("init cart : " + cart); + } + + + + } + */ + + /* 카트 확인 */ + /* + @Test + public void checkCartTest() { + + String memberId = "admin"; + int bookId = 71; + + CartDTO cart = new CartDTO(); + cart.setMemberId(memberId); + cart.setBookId(bookId); + + CartDTO resutlCart = mapper.checkCart(cart); + System.out.println("결과 : " + resutlCart); + + } + */ + +} diff --git a/VamPa/target/classes/com/vam/mapper/CartMapper.xml b/VamPa/target/classes/com/vam/mapper/CartMapper.xml new file mode 100644 index 0000000..664f5bf --- /dev/null +++ b/VamPa/target/classes/com/vam/mapper/CartMapper.xml @@ -0,0 +1,49 @@ + + + + + + + + insert into vam_cart(memberId, bookId, bookCount) + values(#{memberId}, #{bookId}, #{bookCount}) + + + + + + + + delete from vam_cart where cartId = #{cartId} + + + + + + + update vam_cart set bookCount=#{bookCount} where cartId = #{cartId} + + + + + + + + + + + + \ No newline at end of file diff --git a/VamPa/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties b/VamPa/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties index fcffaaa..ffd76fc 100644 --- a/VamPa/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties +++ b/VamPa/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven Integration for Eclipse -#Wed Nov 10 13:50:38 KST 2021 +#Sat Nov 13 22:18:14 KST 2021 m2e.projectLocation=C\:\\Users\\sjinj\\git\\Blog_Project2\\VamPa m2e.projectName=VamPa groupId=com.vam diff --git a/VamPa_MySQL/src/main/java/com/vam/mapper/CartMapper.java b/VamPa_MySQL/src/main/java/com/vam/mapper/CartMapper.java new file mode 100644 index 0000000..714891c --- /dev/null +++ b/VamPa_MySQL/src/main/java/com/vam/mapper/CartMapper.java @@ -0,0 +1,24 @@ +package com.vam.mapper; + +import java.util.List; + +import com.vam.model.CartDTO; + +public interface CartMapper { + + /* 카트 추가 */ + public int addCart(CartDTO cart); + + /* 카트 삭제 */ + public int deleteCart(int cartId); + + /* 카트 수량 수정 */ + public int modifyCount(CartDTO cart); + + /* 카트 목록 */ + public List getCart(String memberId); + + /* 카트 확인 */ + public CartDTO checkCart(CartDTO cart); + +} diff --git a/VamPa_MySQL/src/main/java/com/vam/model/CartDTO.java b/VamPa_MySQL/src/main/java/com/vam/model/CartDTO.java new file mode 100644 index 0000000..55e6490 --- /dev/null +++ b/VamPa_MySQL/src/main/java/com/vam/model/CartDTO.java @@ -0,0 +1,102 @@ +package com.vam.model; + +public class CartDTO { + + private int cartId; + + private String memberId; + + private int bookId; + + private int bookCount; + + //book + + private String bookName; + + private int bookPrice; + + private double bookDiscount; + + // 추가 + private int salePrice; + + private int totalPrice; + + public int getCartId() { + return cartId; + } + + public void setCartId(int cartId) { + this.cartId = cartId; + } + + public String getMemberId() { + return memberId; + } + + public void setMemberId(String memberId) { + this.memberId = memberId; + } + + public int getBookId() { + return bookId; + } + + public void setBookId(int bookId) { + this.bookId = bookId; + } + + public int getBookCount() { + return bookCount; + } + + public void setBookCount(int bookCount) { + this.bookCount = bookCount; + } + + public String getBookName() { + return bookName; + } + + public void setBookName(String bookName) { + this.bookName = bookName; + } + + public int getBookPrice() { + return bookPrice; + } + + public void setBookPrice(int bookPrice) { + this.bookPrice = bookPrice; + } + + public double getBookDiscount() { + return bookDiscount; + } + + public void setBookDiscount(double bookDiscount) { + this.bookDiscount = bookDiscount; + } + + public int getSalePrice() { + return salePrice; + } + + public int getTotalPrice() { + return totalPrice; + } + + public void initSaleTotal() { + this.salePrice = (int) (this.bookPrice * (1-this.bookDiscount)); + this.totalPrice = this.salePrice*this.bookCount; + } + + @Override + public String toString() { + return "CartDTO [cartId=" + cartId + ", memberId=" + memberId + ", bookId=" + bookId + ", bookCount=" + + bookCount + ", bookName=" + bookName + ", bookPrice=" + bookPrice + ", bookDiscount=" + bookDiscount + + ", salePrice=" + salePrice + ", totalPrice=" + totalPrice + "]"; + } + +} diff --git a/VamPa_MySQL/src/main/resources/com/vam/mapper/CartMapper.xml b/VamPa_MySQL/src/main/resources/com/vam/mapper/CartMapper.xml new file mode 100644 index 0000000..664f5bf --- /dev/null +++ b/VamPa_MySQL/src/main/resources/com/vam/mapper/CartMapper.xml @@ -0,0 +1,49 @@ + + + + + + + + insert into vam_cart(memberId, bookId, bookCount) + values(#{memberId}, #{bookId}, #{bookCount}) + + + + + + + + delete from vam_cart where cartId = #{cartId} + + + + + + + update vam_cart set bookCount=#{bookCount} where cartId = #{cartId} + + + + + + + + + + + + \ No newline at end of file diff --git a/VamPa_MySQL/src/test/java/com/vam/mapper/CartMapperTests.java b/VamPa_MySQL/src/test/java/com/vam/mapper/CartMapperTests.java new file mode 100644 index 0000000..81dbdde --- /dev/null +++ b/VamPa_MySQL/src/test/java/com/vam/mapper/CartMapperTests.java @@ -0,0 +1,102 @@ +package com.vam.mapper; + +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration("file:src/main/webapp/WEB-INF/spring/root-context.xml") +public class CartMapperTests { + + @Autowired + private CartMapper mapper; + + /*카트 등록*/ + /* + @Test + public void addCart() { + String memberId = "admin"; + int bookId = 65; + int count = 2; + + CartDTO cart = new CartDTO(); + cart.setMemberId(memberId); + cart.setBookId(bookId); + cart.setBookCount(count); + + int result = 0; + try { + result = mapper.addCart(cart); + } catch (Exception e) { + System.out.println("에러 발생"); + } + + System.out.println("결과 : " + result); + + } + */ + + /* 카트 삭제 */ + /* + @Test + public void deleteCartTest() { + int cartId = 1; + + mapper.deleteCart(cartId); + } + */ + + /* 카트 수량 수정 */ + /* + @Test + public void modifyCartTest() { + int cartId = 3; + int count = 5; + + CartDTO cart = new CartDTO(); + cart.setCartId(cartId); + cart.setBookCount(count); + + mapper.modifyCount(cart); + + } + */ + + /* + @Test + public void getCartTest() { + String memberId = "admin"; + + + List list = mapper.getCart(memberId); + for(CartDTO cart : list) { + System.out.println(cart); + cart.initSaleTotal(); + System.out.println("init cart : " + cart); + } + + + + } + */ + + /* 카트 확인 */ + /* + @Test + public void checkCartTest() { + + String memberId = "admin"; + int bookId = 71; + + CartDTO cart = new CartDTO(); + cart.setMemberId(memberId); + cart.setBookId(bookId); + + CartDTO resutlCart = mapper.checkCart(cart); + System.out.println("결과 : " + resutlCart); + + } + */ + +} diff --git a/VamPa_MySQL/target/classes/com/vam/mapper/CartMapper.xml b/VamPa_MySQL/target/classes/com/vam/mapper/CartMapper.xml new file mode 100644 index 0000000..664f5bf --- /dev/null +++ b/VamPa_MySQL/target/classes/com/vam/mapper/CartMapper.xml @@ -0,0 +1,49 @@ + + + + + + + + insert into vam_cart(memberId, bookId, bookCount) + values(#{memberId}, #{bookId}, #{bookCount}) + + + + + + + + delete from vam_cart where cartId = #{cartId} + + + + + + + update vam_cart set bookCount=#{bookCount} where cartId = #{cartId} + + + + + + + + + + + + \ No newline at end of file diff --git a/VamPa_MySQL/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties b/VamPa_MySQL/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties index 48c4706..e81f609 100644 --- a/VamPa_MySQL/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties +++ b/VamPa_MySQL/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven Integration for Eclipse -#Wed Nov 10 13:48:51 KST 2021 +#Sat Nov 13 22:18:15 KST 2021 m2e.projectLocation=C\:\\Users\\sjinj\\git\\Blog_Project2\\VamPa_MySQL m2e.projectName=VamPa_MySQL groupId=com.vam