From ff0b4e8d40ac7123b8c2c359342600cfb61a6cfa Mon Sep 17 00:00:00 2001 From: SeoJin Kim Date: Wed, 10 Nov 2021 13:51:56 +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][35]=20=EC=83=81=ED=92=88?= =?UTF-8?q?=20=EC=83=81=EC=84=B8=20=ED=8E=98=EC=9D=B4=EC=A7=80=20-=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://kimvampa.tistory.com/258 --- .../com/vam/controller/BookController.java | 12 +++++++++ .../main/java/com/vam/mapper/BookMapper.java | 3 +++ .../java/com/vam/service/BookService.java | 3 +++ .../java/com/vam/service/BookServiceImpl.java | 15 +++++++++++ .../resources/com/vam/mapper/BookMapper.xml | 11 ++++++++ .../java/com/vam/mapper/BookMapperTests.java | 23 ++++++++++++----- .../com/vam/service/BookServiceTests.java | 25 ++++++++++++++++++- .../classes/com/vam/mapper/BookMapper.xml | 11 ++++++++ .../maven/com.vam/controller/pom.properties | 2 +- .../com/vam/controller/BookController.java | 13 ++++++++++ .../main/java/com/vam/mapper/BookMapper.java | 3 +++ .../java/com/vam/service/BookService.java | 5 +++- .../java/com/vam/service/BookServiceImpl.java | 15 +++++++++++ .../resources/com/vam/mapper/BookMapper.xml | 10 ++++++++ .../java/com/vam/mapper/BookMapperTests.java | 19 +++++++++++--- .../com/vam/service/BookServiceTests.java | 17 +++++++++++++ .../classes/com/vam/mapper/BookMapper.xml | 10 ++++++++ .../maven/com.vam/controller/pom.properties | 2 +- 18 files changed, 185 insertions(+), 14 deletions(-) diff --git a/VamPa/src/main/java/com/vam/controller/BookController.java b/VamPa/src/main/java/com/vam/controller/BookController.java index fe6a587..b9dc36b 100644 --- a/VamPa/src/main/java/com/vam/controller/BookController.java +++ b/VamPa/src/main/java/com/vam/controller/BookController.java @@ -16,6 +16,7 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.util.FileCopyUtils; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -117,6 +118,17 @@ public class BookController { } + /* 상품 상세 */ + @GetMapping("/goodsDetail/{bookId}") + public String goodsDetailGET(@PathVariable("bookId")int bookId, Model model) { + + logger.info("goodsDetailGET().........."); + + model.addAttribute("goodsInfo", bookService.getGoodsInfo(bookId)); + + return "/goodsDetail"; + } + } diff --git a/VamPa/src/main/java/com/vam/mapper/BookMapper.java b/VamPa/src/main/java/com/vam/mapper/BookMapper.java index 28b2c45..8f31bd9 100644 --- a/VamPa/src/main/java/com/vam/mapper/BookMapper.java +++ b/VamPa/src/main/java/com/vam/mapper/BookMapper.java @@ -30,4 +30,7 @@ public interface BookMapper { /* 카테고리 정보(+검색대상 갯수) */ public CateFilterDTO getCateInfo(Criteria cri); + /* 상품 정보 */ + public BookVO getGoodsInfo(int bookId); + } diff --git a/VamPa/src/main/java/com/vam/service/BookService.java b/VamPa/src/main/java/com/vam/service/BookService.java index 4d41d0b..93419df 100644 --- a/VamPa/src/main/java/com/vam/service/BookService.java +++ b/VamPa/src/main/java/com/vam/service/BookService.java @@ -24,4 +24,7 @@ public interface BookService { /* 검색결과 카테고리 필터 정보 */ public List getCateInfoList(Criteria cri); + /* 상품 정보 */ + public BookVO getGoodsInfo(int bookId); + } diff --git a/VamPa/src/main/java/com/vam/service/BookServiceImpl.java b/VamPa/src/main/java/com/vam/service/BookServiceImpl.java index 1900b4f..e93310a 100644 --- a/VamPa/src/main/java/com/vam/service/BookServiceImpl.java +++ b/VamPa/src/main/java/com/vam/service/BookServiceImpl.java @@ -6,6 +6,7 @@ import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import com.vam.mapper.AdminMapper; import com.vam.mapper.AttachMapper; import com.vam.mapper.BookMapper; import com.vam.model.AttachImageVO; @@ -26,6 +27,9 @@ public class BookServiceImpl implements BookService{ @Autowired private AttachMapper attachMapper; + @Autowired + private AdminMapper adminMapper; + /* 상품 검색 */ @Override public List getGoodsList(Criteria cri) { @@ -127,4 +131,15 @@ public class BookServiceImpl implements BookService{ return filterInfoList; } + /* 상품 정보 */ + @Override + public BookVO getGoodsInfo(int bookId) { + + BookVO goodsInfo = bookMapper.getGoodsInfo(bookId); + goodsInfo.setImageList(adminMapper.getAttachInfo(bookId)); + + + return goodsInfo; + } + } diff --git a/VamPa/src/main/resources/com/vam/mapper/BookMapper.xml b/VamPa/src/main/resources/com/vam/mapper/BookMapper.xml index e89ee39..27509cd 100644 --- a/VamPa/src/main/resources/com/vam/mapper/BookMapper.xml +++ b/VamPa/src/main/resources/com/vam/mapper/BookMapper.xml @@ -155,6 +155,17 @@ group by a.cateCode, b.cateName + + + + \ No newline at end of file diff --git a/VamPa/src/test/java/com/vam/mapper/BookMapperTests.java b/VamPa/src/test/java/com/vam/mapper/BookMapperTests.java index 8bf1b7a..5c7ec2a 100644 --- a/VamPa/src/test/java/com/vam/mapper/BookMapperTests.java +++ b/VamPa/src/test/java/com/vam/mapper/BookMapperTests.java @@ -79,7 +79,7 @@ public class BookMapperTests { */ /* 검색 (동적 쿼리 적용) - 작가*/ - + /* @Test public void getGoodsListTest1() { // @@ -100,7 +100,7 @@ public class BookMapperTests { System.out.println("list : " + list); } - + */ @@ -199,6 +199,7 @@ public class BookMapperTests { /* 카테고리 리스트 */ + /* @Test public void getCateListTest1() { @@ -220,9 +221,10 @@ public class BookMapperTests { } + */ - - /* 카테고리 정보 얻기 */ + /* 카테고리 정보 얻기 */ + /* @Test public void getCateInfoTest1() { @@ -239,9 +241,18 @@ public class BookMapperTests { mapper.getCateInfo(cri); } - + */ - + /* 상품 정보 */ + @Test + public void getGoodsInfo() { + int bookId = 26; + BookVO goodsInfo = mapper.getGoodsInfo(bookId); + System.out.println("==========================="); + System.out.println(goodsInfo); + System.out.println("==========================="); + + } diff --git a/VamPa/src/test/java/com/vam/service/BookServiceTests.java b/VamPa/src/test/java/com/vam/service/BookServiceTests.java index 32459e1..b6e4e34 100644 --- a/VamPa/src/test/java/com/vam/service/BookServiceTests.java +++ b/VamPa/src/test/java/com/vam/service/BookServiceTests.java @@ -6,7 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import com.vam.model.Criteria; +import com.vam.model.BookVO; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("file:src/main/webapp/WEB-INF/spring/root-context.xml") @@ -15,6 +15,7 @@ public class BookServiceTests { @Autowired BookService service; + /* @Test public void getCateInfoListTest1() { Criteria cri = new Criteria(); @@ -31,7 +32,9 @@ public class BookServiceTests { System.out.println("List : " + service.getCateInfoList(cri)); } + */ + /* @Test public void getCateInfoListTest2() { Criteria cri = new Criteria(); @@ -48,7 +51,9 @@ public class BookServiceTests { System.out.println("List : " + service.getCateInfoList(cri)); } + */ + /* @Test public void getCateInfoListTest3() { Criteria cri = new Criteria(); @@ -64,7 +69,9 @@ public class BookServiceTests { System.out.println("List : " + service.getCateInfoList(cri)); } + */ + /* @Test public void getCateInfoListTest4() { Criteria cri = new Criteria(); @@ -80,7 +87,23 @@ public class BookServiceTests { System.out.println("List : " + service.getCateInfoList(cri)); } + */ + /*상품 상세 정보*/ + @Test + public void getGoodsInfoTest() { + + int bookId = 1166; + + BookVO goodsInfo = service.getGoodsInfo(bookId); + + System.out.println("==결과=="); + System.out.println("전체 : " + goodsInfo); + System.out.println("bookId : " + goodsInfo.getBookId() ); + System.out.println("이미지 정보 : " + goodsInfo.getImageList().isEmpty()); + + + } } diff --git a/VamPa/target/classes/com/vam/mapper/BookMapper.xml b/VamPa/target/classes/com/vam/mapper/BookMapper.xml index e89ee39..27509cd 100644 --- a/VamPa/target/classes/com/vam/mapper/BookMapper.xml +++ b/VamPa/target/classes/com/vam/mapper/BookMapper.xml @@ -155,6 +155,17 @@ group by a.cateCode, b.cateName + + + + \ 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 61718ee..fcffaaa 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 -#Sun Oct 03 21:07:48 KST 2021 +#Wed Nov 10 13:50:38 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/controller/BookController.java b/VamPa_MySQL/src/main/java/com/vam/controller/BookController.java index d87e312..27c469d 100644 --- a/VamPa_MySQL/src/main/java/com/vam/controller/BookController.java +++ b/VamPa_MySQL/src/main/java/com/vam/controller/BookController.java @@ -16,6 +16,7 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.util.FileCopyUtils; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -117,5 +118,17 @@ public class BookController { } + /* 상품 상세 */ + @GetMapping("/goodsDetail/{bookId}") + public String goodsDetailGET(@PathVariable("bookId")int bookId, Model model) { + + logger.info("goodsDetailGET().........."); + + model.addAttribute("goodsInfo", bookService.getGoodsInfo(bookId)); + + return "/goodsDetail"; + } + + } diff --git a/VamPa_MySQL/src/main/java/com/vam/mapper/BookMapper.java b/VamPa_MySQL/src/main/java/com/vam/mapper/BookMapper.java index 6721633..68fca2b 100644 --- a/VamPa_MySQL/src/main/java/com/vam/mapper/BookMapper.java +++ b/VamPa_MySQL/src/main/java/com/vam/mapper/BookMapper.java @@ -30,4 +30,7 @@ public interface BookMapper { /* 카테고리 정보(+검색대상 갯수) */ public CateFilterDTO getCateInfo(Criteria cri); + /* 상품 정보 */ + public BookVO getGoodsInfo(int bookId); + } diff --git a/VamPa_MySQL/src/main/java/com/vam/service/BookService.java b/VamPa_MySQL/src/main/java/com/vam/service/BookService.java index 833338b..25e17b3 100644 --- a/VamPa_MySQL/src/main/java/com/vam/service/BookService.java +++ b/VamPa_MySQL/src/main/java/com/vam/service/BookService.java @@ -22,6 +22,9 @@ public interface BookService { public List getCateCode2(); /* 검색결과 카테고리 필터 정보 */ - public List getCateInfoList(Criteria cri); + public List getCateInfoList(Criteria cri); + + /* 상품 정보 */ + public BookVO getGoodsInfo(int bookId); } diff --git a/VamPa_MySQL/src/main/java/com/vam/service/BookServiceImpl.java b/VamPa_MySQL/src/main/java/com/vam/service/BookServiceImpl.java index eb7be49..3b6d2dd 100644 --- a/VamPa_MySQL/src/main/java/com/vam/service/BookServiceImpl.java +++ b/VamPa_MySQL/src/main/java/com/vam/service/BookServiceImpl.java @@ -6,6 +6,7 @@ import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import com.vam.mapper.AdminMapper; import com.vam.mapper.AttachMapper; import com.vam.mapper.BookMapper; import com.vam.model.AttachImageVO; @@ -26,6 +27,9 @@ public class BookServiceImpl implements BookService{ @Autowired private AttachMapper attachMapper; + @Autowired + private AdminMapper adminMapper; + /* 상품 검색 */ @Override public List getGoodsList(Criteria cri) { @@ -126,4 +130,15 @@ public class BookServiceImpl implements BookService{ return filterInfoList; } + /* 상품 정보 */ + @Override + public BookVO getGoodsInfo(int bookId) { + + BookVO goodsInfo = bookMapper.getGoodsInfo(bookId); + goodsInfo.setImageList(adminMapper.getAttachInfo(bookId)); + + + return goodsInfo; + } + } diff --git a/VamPa_MySQL/src/main/resources/com/vam/mapper/BookMapper.xml b/VamPa_MySQL/src/main/resources/com/vam/mapper/BookMapper.xml index 37cf62c..fc7720c 100644 --- a/VamPa_MySQL/src/main/resources/com/vam/mapper/BookMapper.xml +++ b/VamPa_MySQL/src/main/resources/com/vam/mapper/BookMapper.xml @@ -141,6 +141,16 @@ + + + \ No newline at end of file diff --git a/VamPa_MySQL/src/test/java/com/vam/mapper/BookMapperTests.java b/VamPa_MySQL/src/test/java/com/vam/mapper/BookMapperTests.java index bc518a7..515be4e 100644 --- a/VamPa_MySQL/src/test/java/com/vam/mapper/BookMapperTests.java +++ b/VamPa_MySQL/src/test/java/com/vam/mapper/BookMapperTests.java @@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import com.vam.model.BookVO; import com.vam.model.CateFilterDTO; import com.vam.model.Criteria; @@ -53,7 +54,7 @@ public class BookMapperTests { */ /* 카테고리 리스트 얻기 */ - + /* @Test public void getCateListTest1() { @@ -75,10 +76,11 @@ public class BookMapperTests { } - + */ /* 카테고리 정보 얻기 */ + /* @Test public void getCateInfoTest1() { @@ -95,8 +97,17 @@ public class BookMapperTests { mapper.getCateInfo(cri); } - - + */ + /* 상품 정보 */ + @Test + public void getGoodsInfo() { + int bookId = 26; + BookVO goodsInfo = mapper.getGoodsInfo(bookId); + System.out.println("==========================="); + System.out.println(goodsInfo); + System.out.println("==========================="); + + } diff --git a/VamPa_MySQL/src/test/java/com/vam/service/BookServiceTests.java b/VamPa_MySQL/src/test/java/com/vam/service/BookServiceTests.java index f4b0ab1..2e77bd2 100644 --- a/VamPa_MySQL/src/test/java/com/vam/service/BookServiceTests.java +++ b/VamPa_MySQL/src/test/java/com/vam/service/BookServiceTests.java @@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import com.vam.model.BookVO; import com.vam.model.Criteria; @RunWith(SpringJUnit4ClassRunner.class) @@ -81,4 +82,20 @@ public class BookServiceTests { } + /*상품 상세 정보*/ + @Test + public void getGoodsInfoTest() { + + int bookId = 1166; + + BookVO goodsInfo = service.getGoodsInfo(bookId); + + System.out.println("==결과=="); + System.out.println("전체 : " + goodsInfo); + System.out.println("bookId : " + goodsInfo.getBookId() ); + System.out.println("이미지 정보 : " + goodsInfo.getImageList().isEmpty()); + + + } + } diff --git a/VamPa_MySQL/target/classes/com/vam/mapper/BookMapper.xml b/VamPa_MySQL/target/classes/com/vam/mapper/BookMapper.xml index 37cf62c..fc7720c 100644 --- a/VamPa_MySQL/target/classes/com/vam/mapper/BookMapper.xml +++ b/VamPa_MySQL/target/classes/com/vam/mapper/BookMapper.xml @@ -141,6 +141,16 @@ + + + \ 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 ce7d0a6..48c4706 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 -#Sun Oct 03 21:07:49 KST 2021 +#Wed Nov 10 13:48:51 KST 2021 m2e.projectLocation=C\:\\Users\\sjinj\\git\\Blog_Project2\\VamPa_MySQL m2e.projectName=VamPa_MySQL groupId=com.vam