@@ -105,6 +105,13 @@ public class BookController {
|
||||
|
||||
model.addAttribute("pageMaker", new PageDTO(cri, bookService.goodsGetTotal(cri)));
|
||||
|
||||
String[] typeArr = cri.getType().split("");
|
||||
|
||||
for(String s : typeArr) {
|
||||
if(s.equals("T") || s.equals("A")) {
|
||||
model.addAttribute("filter_info", bookService.getCateInfoList(cri));
|
||||
}
|
||||
}
|
||||
|
||||
return "search";
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.vam.service;
|
||||
import java.util.List;
|
||||
|
||||
import com.vam.model.BookVO;
|
||||
import com.vam.model.CateFilterDTO;
|
||||
import com.vam.model.CateVO;
|
||||
import com.vam.model.Criteria;
|
||||
|
||||
@@ -18,6 +19,9 @@ public interface BookService {
|
||||
public List<CateVO> getCateCode1();
|
||||
|
||||
/* 외국 카테고리 리스트 */
|
||||
public List<CateVO> getCateCode2();
|
||||
public List<CateVO> getCateCode2();
|
||||
|
||||
/* 검색결과 카테고리 필터 정보 */
|
||||
public List<CateFilterDTO> getCateInfoList(Criteria cri);
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.vam.mapper.AttachMapper;
|
||||
import com.vam.mapper.BookMapper;
|
||||
import com.vam.model.AttachImageVO;
|
||||
import com.vam.model.BookVO;
|
||||
import com.vam.model.CateFilterDTO;
|
||||
import com.vam.model.CateVO;
|
||||
import com.vam.model.Criteria;
|
||||
|
||||
@@ -89,6 +90,41 @@ public class BookServiceImpl implements BookService{
|
||||
log.info("getCateCode2().........");
|
||||
|
||||
return bookMapper.getCateCode2();
|
||||
}
|
||||
|
||||
|
||||
/* 검색결과 카테고리 필터 정보 */
|
||||
@Override
|
||||
public List<CateFilterDTO> getCateInfoList(Criteria cri) {
|
||||
|
||||
List<CateFilterDTO> filterInfoList = new ArrayList<CateFilterDTO>();
|
||||
|
||||
String[] typeArr = cri.getType().split("");
|
||||
String [] authorArr;
|
||||
|
||||
for(String type : typeArr) {
|
||||
if(type.equals("A")){
|
||||
authorArr = bookMapper.getAuthorIdList(cri.getKeyword());
|
||||
if(authorArr.length == 0) {
|
||||
return filterInfoList;
|
||||
}
|
||||
cri.setAuthorArr(authorArr);
|
||||
}
|
||||
}
|
||||
|
||||
String[] cateList = bookMapper.getCateList(cri);
|
||||
|
||||
String tempCateCode = cri.getCateCode();
|
||||
|
||||
for(String cateCode : cateList) {
|
||||
cri.setCateCode(cateCode);
|
||||
CateFilterDTO filterInfo = bookMapper.getCateInfo(cri);
|
||||
filterInfoList.add(filterInfo);
|
||||
}
|
||||
|
||||
cri.setCateCode(tempCateCode);
|
||||
|
||||
return filterInfoList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
86
VamPa/src/test/java/com/vam/service/BookServiceTests.java
Normal file
86
VamPa/src/test/java/com/vam/service/BookServiceTests.java
Normal file
@@ -0,0 +1,86 @@
|
||||
package com.vam.service;
|
||||
|
||||
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.Criteria;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("file:src/main/webapp/WEB-INF/spring/root-context.xml")
|
||||
public class BookServiceTests {
|
||||
|
||||
@Autowired
|
||||
BookService service;
|
||||
|
||||
@Test
|
||||
public void getCateInfoListTest1() {
|
||||
Criteria cri = new Criteria();
|
||||
|
||||
String type = "TC";
|
||||
//String keyword = "테스트";
|
||||
String keyword = "없음";
|
||||
String cateCode="103002";
|
||||
|
||||
cri.setType(type);
|
||||
cri.setKeyword(keyword);
|
||||
cri.setCateCode(cateCode);
|
||||
|
||||
System.out.println("List<CateFilterDTO> : " + service.getCateInfoList(cri));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCateInfoListTest2() {
|
||||
Criteria cri = new Criteria();
|
||||
|
||||
String type = "AC";
|
||||
String keyword = "유홍준"; // 카테고리에 존재하는 작가
|
||||
//String keyword = "머스크"; // 카테고리에 존재하지 않는 작가
|
||||
String cateCode = "103002";
|
||||
|
||||
cri.setType(type);
|
||||
cri.setKeyword(keyword);
|
||||
cri.setCateCode(cateCode);
|
||||
|
||||
System.out.println("List<CateFilterDTO> : " + service.getCateInfoList(cri));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCateInfoListTest3() {
|
||||
Criteria cri = new Criteria();
|
||||
|
||||
String type = "T";
|
||||
String keyword = "테스트";
|
||||
//String keyword = "없음";
|
||||
|
||||
|
||||
cri.setType(type);
|
||||
cri.setKeyword(keyword);
|
||||
|
||||
System.out.println("List<CateFilterDTO> : " + service.getCateInfoList(cri));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCateInfoListTest4() {
|
||||
Criteria cri = new Criteria();
|
||||
|
||||
String type = "AC";
|
||||
//String keyword = "유홍준"; // 카테고리에 존재하는 작가
|
||||
String keyword = "머스크"; // 카테고리에 존재하지 않는 작가
|
||||
|
||||
|
||||
cri.setType(type);
|
||||
cri.setKeyword(keyword);
|
||||
|
||||
System.out.println("List<CateFilterDTO> : " + service.getCateInfoList(cri));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#Generated by Maven Integration for Eclipse
|
||||
#Mon Sep 27 14:58:55 KST 2021
|
||||
#Sun Oct 03 21:07:48 KST 2021
|
||||
m2e.projectLocation=C\:\\Users\\sjinj\\git\\Blog_Project2\\VamPa
|
||||
m2e.projectName=VamPa
|
||||
groupId=com.vam
|
||||
|
||||
@@ -105,6 +105,13 @@ public class BookController {
|
||||
|
||||
model.addAttribute("pageMaker", new PageDTO(cri, bookService.goodsGetTotal(cri)));
|
||||
|
||||
String[] typeArr = cri.getType().split("");
|
||||
|
||||
for(String s : typeArr) {
|
||||
if(s.equals("T") || s.equals("A")) {
|
||||
model.addAttribute("filter_info", bookService.getCateInfoList(cri));
|
||||
}
|
||||
}
|
||||
|
||||
return "search";
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.vam.service;
|
||||
import java.util.List;
|
||||
|
||||
import com.vam.model.BookVO;
|
||||
import com.vam.model.CateFilterDTO;
|
||||
import com.vam.model.CateVO;
|
||||
import com.vam.model.Criteria;
|
||||
|
||||
@@ -18,6 +19,9 @@ public interface BookService {
|
||||
public List<CateVO> getCateCode1();
|
||||
|
||||
/* 외국 카테고리 리스트 */
|
||||
public List<CateVO> getCateCode2();
|
||||
public List<CateVO> getCateCode2();
|
||||
|
||||
/* 검색결과 카테고리 필터 정보 */
|
||||
public List<CateFilterDTO> getCateInfoList(Criteria cri);
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.vam.mapper.AttachMapper;
|
||||
import com.vam.mapper.BookMapper;
|
||||
import com.vam.model.AttachImageVO;
|
||||
import com.vam.model.BookVO;
|
||||
import com.vam.model.CateFilterDTO;
|
||||
import com.vam.model.CateVO;
|
||||
import com.vam.model.Criteria;
|
||||
|
||||
@@ -91,4 +92,38 @@ public class BookServiceImpl implements BookService{
|
||||
return bookMapper.getCateCode2();
|
||||
}
|
||||
|
||||
/* 검색결과 카테고리 필터 정보 */
|
||||
@Override
|
||||
public List<CateFilterDTO> getCateInfoList(Criteria cri) {
|
||||
|
||||
List<CateFilterDTO> filterInfoList = new ArrayList<CateFilterDTO>();
|
||||
|
||||
String[] typeArr = cri.getType().split("");
|
||||
String [] authorArr;
|
||||
|
||||
for(String type : typeArr) {
|
||||
if(type.equals("A")){
|
||||
authorArr = bookMapper.getAuthorIdList(cri.getKeyword());
|
||||
if(authorArr.length == 0) {
|
||||
return filterInfoList;
|
||||
}
|
||||
cri.setAuthorArr(authorArr);
|
||||
}
|
||||
}
|
||||
|
||||
String[] cateList = bookMapper.getCateList(cri);
|
||||
|
||||
String tempCateCode = cri.getCateCode();
|
||||
|
||||
for(String cateCode : cateList) {
|
||||
cri.setCateCode(cateCode);
|
||||
CateFilterDTO filterInfo = bookMapper.getCateInfo(cri);
|
||||
filterInfoList.add(filterInfo);
|
||||
}
|
||||
|
||||
cri.setCateCode(tempCateCode);
|
||||
|
||||
return filterInfoList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.vam.service;
|
||||
|
||||
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.Criteria;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("file:src/main/webapp/WEB-INF/spring/root-context.xml")
|
||||
public class BookServiceTests {
|
||||
|
||||
@Autowired
|
||||
BookService service;
|
||||
|
||||
@Test
|
||||
public void getCateInfoListTest1() {
|
||||
Criteria cri = new Criteria();
|
||||
|
||||
String type = "TC";
|
||||
//String keyword = "테스트";
|
||||
String keyword = "없음";
|
||||
String cateCode="103002";
|
||||
|
||||
cri.setType(type);
|
||||
cri.setKeyword(keyword);
|
||||
cri.setCateCode(cateCode);
|
||||
|
||||
System.out.println("List<CateFilterDTO> : " + service.getCateInfoList(cri));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCateInfoListTest2() {
|
||||
Criteria cri = new Criteria();
|
||||
|
||||
String type = "AC";
|
||||
String keyword = "유홍준"; // 카테고리에 존재하는 작가
|
||||
//String keyword = "머스크"; // 카테고리에 존재하지 않는 작가
|
||||
String cateCode = "103002";
|
||||
|
||||
cri.setType(type);
|
||||
cri.setKeyword(keyword);
|
||||
cri.setCateCode(cateCode);
|
||||
|
||||
System.out.println("List<CateFilterDTO> : " + service.getCateInfoList(cri));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCateInfoListTest3() {
|
||||
Criteria cri = new Criteria();
|
||||
|
||||
String type = "T";
|
||||
String keyword = "테스트";
|
||||
//String keyword = "없음";
|
||||
|
||||
|
||||
cri.setType(type);
|
||||
cri.setKeyword(keyword);
|
||||
|
||||
System.out.println("List<CateFilterDTO> : " + service.getCateInfoList(cri));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCateInfoListTest4() {
|
||||
Criteria cri = new Criteria();
|
||||
|
||||
String type = "AC";
|
||||
//String keyword = "유홍준"; // 카테고리에 존재하는 작가
|
||||
String keyword = "머스크"; // 카테고리에 존재하지 않는 작가
|
||||
|
||||
|
||||
cri.setType(type);
|
||||
cri.setKeyword(keyword);
|
||||
|
||||
System.out.println("List<CateFilterDTO> : " + service.getCateInfoList(cri));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#Generated by Maven Integration for Eclipse
|
||||
#Mon Sep 27 14:58:56 KST 2021
|
||||
#Sun Oct 03 21:07:49 KST 2021
|
||||
m2e.projectLocation=C\:\\Users\\sjinj\\git\\Blog_Project2\\VamPa_MySQL
|
||||
m2e.projectName=VamPa_MySQL
|
||||
groupId=com.vam
|
||||
|
||||
Reference in New Issue
Block a user