[Spring][쇼핑몰 프로젝트][31] 검색 구현(조건 검색 적용 -1)
https://kimvampa.tistory.com/245
This commit is contained in:
@@ -13,4 +13,7 @@ public interface BookMapper {
|
||||
/* 상품 총 갯수 */
|
||||
public int goodsGetTotal(Criteria cri);
|
||||
|
||||
/* 작가 id 리스트 요청 */
|
||||
public String[] getAuthorIdList(String keyword);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.vam.model;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Criteria {
|
||||
|
||||
/* 현재 페이지 번호 */
|
||||
@@ -14,6 +16,12 @@ public class Criteria {
|
||||
/* 검색 키워드 */
|
||||
private String keyword;
|
||||
|
||||
/* 작가 리스트 */
|
||||
private String[] authorArr;
|
||||
|
||||
/* 카테고리 코드 */
|
||||
private String cateCode;
|
||||
|
||||
/* Criteria 생성자 */
|
||||
public Criteria(int pageNum, int amount) {
|
||||
this.pageNum = pageNum;
|
||||
@@ -62,10 +70,28 @@ public class Criteria {
|
||||
this.keyword = keyword;
|
||||
}
|
||||
|
||||
public String[] getAuthorArr() {
|
||||
return authorArr;
|
||||
}
|
||||
|
||||
public void setAuthorArr(String[] authorArr) {
|
||||
this.authorArr = authorArr;
|
||||
}
|
||||
|
||||
public String getCateCode() {
|
||||
return cateCode;
|
||||
}
|
||||
|
||||
public void setCateCode(String cateCode) {
|
||||
this.cateCode = cateCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Criteria [pageNum=" + pageNum + ", amount=" + amount + ", type=" + type + ", keyword=" + keyword + "]";
|
||||
return "Criteria [pageNum=" + pageNum + ", amount=" + amount + ", type=" + type + ", keyword=" + keyword
|
||||
+ ", authorArr=" + Arrays.toString(authorArr) + ", cateCode=" + cateCode + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,16 @@ public class BookServiceImpl implements BookService{
|
||||
|
||||
log.info("getGoodsList().......");
|
||||
|
||||
String type = cri.getType();
|
||||
String[] typeArr = type.split("");
|
||||
|
||||
for(String t : typeArr) {
|
||||
if(t.equals("A")) {
|
||||
String[] authorArr = bookMapper.getAuthorIdList(cri.getKeyword());
|
||||
cri.setAuthorArr(authorArr);
|
||||
}
|
||||
}
|
||||
|
||||
return bookMapper.getGoodsList(cri);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,14 @@
|
||||
<include refid="criteria"></include>
|
||||
bookId >0
|
||||
|
||||
</select>
|
||||
|
||||
<!-- 작가 id 리스트 요청 -->
|
||||
<select id="getAuthorIdList" resultType="String">
|
||||
|
||||
select authorid from vam_author where authorName like '%' || #{keyword} || '%'
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -18,6 +18,7 @@ public class BookMapperTests {
|
||||
@Autowired
|
||||
private BookMapper mapper;
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void getGoodsListTest() {
|
||||
|
||||
@@ -34,5 +35,25 @@ public class BookMapperTests {
|
||||
System.out.println("totla : " + goodsTotal);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
/* 작가 id 리스트 요청 */
|
||||
|
||||
@Test
|
||||
public void getAuthorId() {
|
||||
|
||||
String keyword = "폴";
|
||||
|
||||
String[] list = mapper.getAuthorIdList(keyword);
|
||||
|
||||
System.out.println("결과 : " + list.toString());
|
||||
|
||||
for(String id : list) {
|
||||
System.out.println("개별 결과 : " + id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -42,6 +42,14 @@
|
||||
<include refid="criteria"></include>
|
||||
bookId >0
|
||||
|
||||
</select>
|
||||
|
||||
<!-- 작가 id 리스트 요청 -->
|
||||
<select id="getAuthorIdList" resultType="String">
|
||||
|
||||
select authorid from vam_author where authorName like '%' || #{keyword} || '%'
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -13,4 +13,7 @@ public interface BookMapper {
|
||||
/* 상품 총 갯수 */
|
||||
public int goodsGetTotal(Criteria cri);
|
||||
|
||||
/* 작가 id 리스트 요청 */
|
||||
public String[] getAuthorIdList(String keyword);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.vam.model;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Criteria {
|
||||
|
||||
/* 현재 페이지 번호 */
|
||||
@@ -17,6 +19,12 @@ public class Criteria {
|
||||
/* 검색 키워드 */
|
||||
private String keyword;
|
||||
|
||||
/* 작가 리스트 */
|
||||
private String[] authorArr;
|
||||
|
||||
/* 카테고리 코드 */
|
||||
private String cateCode;
|
||||
|
||||
/* Criteria 생성자 */
|
||||
public Criteria(int pageNum, int amount) {
|
||||
this.pageNum = pageNum;
|
||||
@@ -76,10 +84,27 @@ public class Criteria {
|
||||
this.keyword = keyword;
|
||||
}
|
||||
|
||||
|
||||
public String[] getAuthorArr() {
|
||||
return authorArr;
|
||||
}
|
||||
|
||||
public void setAuthorArr(String[] authorArr) {
|
||||
this.authorArr = authorArr;
|
||||
}
|
||||
|
||||
public String getCateCode() {
|
||||
return cateCode;
|
||||
}
|
||||
|
||||
public void setCateCode(String cateCode) {
|
||||
this.cateCode = cateCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Criteria [pageNum=" + pageNum + ", amount=" + amount + ", skip=" + skip + ", type=" + type
|
||||
+ ", keyword=" + keyword + "]";
|
||||
return "Criteria [pageNum=" + pageNum + ", amount=" + amount + ", type=" + type + ", keyword=" + keyword
|
||||
+ ", authorArr=" + Arrays.toString(authorArr) + ", cateCode=" + cateCode + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -24,6 +24,16 @@ public class BookServiceImpl implements BookService{
|
||||
|
||||
log.info("getGoodsList().......");
|
||||
|
||||
String type = cri.getType();
|
||||
String[] typeArr = type.split("");
|
||||
|
||||
for(String t : typeArr) {
|
||||
if(t.equals("A")) {
|
||||
String[] authorArr = bookMapper.getAuthorIdList(cri.getKeyword());
|
||||
cri.setAuthorArr(authorArr);
|
||||
}
|
||||
}
|
||||
|
||||
return bookMapper.getGoodsList(cri);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,13 @@
|
||||
|
||||
<include refid="criteria"></include>
|
||||
|
||||
</select>
|
||||
</select>
|
||||
|
||||
<!-- 작가 id 리스트 요청 -->
|
||||
<select id="getAuthorIdList" resultType="String">
|
||||
|
||||
select authorid from vam_author where authorname like concat ('%', #{keyword}, '%')
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -16,7 +16,7 @@ import com.vam.model.Criteria;
|
||||
public class BookMapperTests {
|
||||
@Autowired
|
||||
private BookMapper mapper;
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void getGoodsListTest() {
|
||||
|
||||
@@ -33,5 +33,24 @@ public class BookMapperTests {
|
||||
System.out.println("totla : " + goodsTotal);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
/* 작가 id 리스트 요청 */
|
||||
|
||||
@Test
|
||||
public void getAuthorId() {
|
||||
|
||||
String keyword = "폴";
|
||||
|
||||
String[] list = mapper.getAuthorIdList(keyword);
|
||||
|
||||
System.out.println("결과 : " + list.toString());
|
||||
|
||||
for(String id : list) {
|
||||
System.out.println("개별 결과 : " + id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,6 +30,13 @@
|
||||
|
||||
<include refid="criteria"></include>
|
||||
|
||||
</select>
|
||||
</select>
|
||||
|
||||
<!-- 작가 id 리스트 요청 -->
|
||||
<select id="getAuthorIdList" resultType="String">
|
||||
|
||||
select authorid from vam_author where authorname like concat ('%', #{keyword}, '%')
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user