@@ -3,6 +3,7 @@ package com.vam.mapper;
|
||||
import java.util.List;
|
||||
|
||||
import com.vam.model.BookVO;
|
||||
import com.vam.model.CateFilterDTO;
|
||||
import com.vam.model.CateVO;
|
||||
import com.vam.model.Criteria;
|
||||
|
||||
@@ -23,4 +24,10 @@ public interface BookMapper {
|
||||
/* 외국 카테고리 리스트 */
|
||||
public List<CateVO> getCateCode2();
|
||||
|
||||
/* 검색 대상 카테고리 리스트 */
|
||||
public String[] getCateList(Criteria cri);
|
||||
|
||||
/* 카테고리 정보(+검색대상 갯수) */
|
||||
public CateFilterDTO getCateInfo(Criteria cri);
|
||||
|
||||
}
|
||||
|
||||
56
VamPa/src/main/java/com/vam/model/CateFilterDTO.java
Normal file
56
VamPa/src/main/java/com/vam/model/CateFilterDTO.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package com.vam.model;
|
||||
|
||||
public class CateFilterDTO {
|
||||
|
||||
/* 카테고리 이름 */
|
||||
private String cateName;
|
||||
|
||||
/* 카테고리 넘버 */
|
||||
private String cateCode;;
|
||||
|
||||
/* 카테고리 상품 수 */
|
||||
private int cateCount;
|
||||
|
||||
/* 국내,국외 분류 */
|
||||
private String cateGroup;
|
||||
|
||||
public String getCateName() {
|
||||
return cateName;
|
||||
}
|
||||
|
||||
public void setCateName(String cateName) {
|
||||
this.cateName = cateName;
|
||||
}
|
||||
|
||||
public String getCateCode() {
|
||||
return cateCode;
|
||||
}
|
||||
|
||||
public void setCateCode(String cateCode) {
|
||||
this.cateCode = cateCode;
|
||||
this.cateGroup = cateCode.split("")[0];
|
||||
}
|
||||
|
||||
public int getCateCount() {
|
||||
return cateCount;
|
||||
}
|
||||
|
||||
public void setCateCount(int cateCount) {
|
||||
this.cateCount = cateCount;
|
||||
}
|
||||
|
||||
public String getCateGroup() {
|
||||
return cateGroup;
|
||||
}
|
||||
|
||||
public void setCateGroup(String cateGroup) {
|
||||
this.cateGroup = cateGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CateFilterDTO [cateName=" + cateName + ", cateCode=" + cateCode + ", cateCount=" + cateCount
|
||||
+ ", cateGroup=" + cateGroup + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -89,6 +89,72 @@
|
||||
]]>
|
||||
|
||||
</select>
|
||||
|
||||
<!-- 검색 대상 카테고리 리스트 -->
|
||||
<select id="getCateList" resultType="String">
|
||||
|
||||
select DISTINCT cateCode from vam_book where
|
||||
<foreach item="type" collection="typeArr">
|
||||
<choose>
|
||||
<when test="type == 'A'.toString()">
|
||||
<trim prefixOverrides="or">
|
||||
<foreach collection="authorArr" item="authorId">
|
||||
<trim prefix="or">
|
||||
authorId = #{authorId}
|
||||
</trim>
|
||||
</foreach>
|
||||
</trim>
|
||||
</when>
|
||||
<when test="type == 'T'.toString()">
|
||||
bookName like '%' || #{keyword} || '%'
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
|
||||
</select>
|
||||
|
||||
<!-- 카테고리 정보(+검색대상 갯수) -->
|
||||
|
||||
<select id="getCateInfo" resultType="com.vam.model.CateFilterDTO">
|
||||
|
||||
select DISTINCT count(*) cateCount, a.cateCode, b.cateName from vam_book a left join vam_bcate b on a.cateCode = b.cateCode
|
||||
|
||||
where
|
||||
|
||||
<foreach item="type" collection="typeArr">
|
||||
<choose>
|
||||
<when test="type == 'A'.toString()">
|
||||
|
||||
<trim prefix="(" suffix=")" prefixOverrides="or">
|
||||
|
||||
<foreach collection="authorArr" item="authorId">
|
||||
|
||||
<trim prefix="or">
|
||||
|
||||
authorId = #{authorId}
|
||||
|
||||
</trim>
|
||||
|
||||
</foreach>
|
||||
|
||||
</trim>
|
||||
|
||||
and a.cateCode = #{cateCode}
|
||||
|
||||
</when>
|
||||
|
||||
<when test="type == 'T'.toString()">
|
||||
|
||||
bookName like '%' || #{keyword} || '%' and a.cateCode = #{cateCode}
|
||||
|
||||
</when>
|
||||
|
||||
</choose>
|
||||
</foreach>
|
||||
|
||||
group by a.cateCode, b.cateName
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -198,6 +198,49 @@ public class BookMapperTests {
|
||||
*/
|
||||
|
||||
|
||||
/* 카테고리 리스트 */
|
||||
@Test
|
||||
public void getCateListTest1() {
|
||||
|
||||
Criteria cri = new Criteria();
|
||||
|
||||
String type = "TC";
|
||||
String keyword = "test";
|
||||
//String type = "A";
|
||||
//String keyword = "유홍준";
|
||||
|
||||
cri.setType(type);
|
||||
cri.setKeyword(keyword);
|
||||
//cri.setAuthorArr(mapper.getAuthorIdList(keyword));
|
||||
|
||||
String[] cateList = mapper.getCateList(cri) ;
|
||||
for(String codeNum : cateList) {
|
||||
System.out.println("codeNum ::::: " + codeNum);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* 카테고리 정보 얻기 */
|
||||
@Test
|
||||
public void getCateInfoTest1() {
|
||||
|
||||
Criteria cri = new Criteria();
|
||||
|
||||
String type = "TC";
|
||||
String keyword = "test";
|
||||
String cateCode="103002";
|
||||
|
||||
cri.setType(type);
|
||||
cri.setKeyword(keyword);
|
||||
cri.setCateCode(cateCode);
|
||||
|
||||
mapper.getCateInfo(cri);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -89,6 +89,72 @@
|
||||
]]>
|
||||
|
||||
</select>
|
||||
|
||||
<!-- 검색 대상 카테고리 리스트 -->
|
||||
<select id="getCateList" resultType="String">
|
||||
|
||||
select DISTINCT cateCode from vam_book where
|
||||
<foreach item="type" collection="typeArr">
|
||||
<choose>
|
||||
<when test="type == 'A'.toString()">
|
||||
<trim prefixOverrides="or">
|
||||
<foreach collection="authorArr" item="authorId">
|
||||
<trim prefix="or">
|
||||
authorId = #{authorId}
|
||||
</trim>
|
||||
</foreach>
|
||||
</trim>
|
||||
</when>
|
||||
<when test="type == 'T'.toString()">
|
||||
bookName like '%' || #{keyword} || '%'
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
|
||||
</select>
|
||||
|
||||
<!-- 카테고리 정보(+검색대상 갯수) -->
|
||||
|
||||
<select id="getCateInfo" resultType="com.vam.model.CateFilterDTO">
|
||||
|
||||
select DISTINCT count(*) cateCount, a.cateCode, b.cateName from vam_book a left join vam_bcate b on a.cateCode = b.cateCode
|
||||
|
||||
where
|
||||
|
||||
<foreach item="type" collection="typeArr">
|
||||
<choose>
|
||||
<when test="type == 'A'.toString()">
|
||||
|
||||
<trim prefix="(" suffix=")" prefixOverrides="or">
|
||||
|
||||
<foreach collection="authorArr" item="authorId">
|
||||
|
||||
<trim prefix="or">
|
||||
|
||||
authorId = #{authorId}
|
||||
|
||||
</trim>
|
||||
|
||||
</foreach>
|
||||
|
||||
</trim>
|
||||
|
||||
and a.cateCode = #{cateCode}
|
||||
|
||||
</when>
|
||||
|
||||
<when test="type == 'T'.toString()">
|
||||
|
||||
bookName like '%' || #{keyword} || '%' and a.cateCode = #{cateCode}
|
||||
|
||||
</when>
|
||||
|
||||
</choose>
|
||||
</foreach>
|
||||
|
||||
group by a.cateCode, b.cateName
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -3,6 +3,7 @@ package com.vam.mapper;
|
||||
import java.util.List;
|
||||
|
||||
import com.vam.model.BookVO;
|
||||
import com.vam.model.CateFilterDTO;
|
||||
import com.vam.model.CateVO;
|
||||
import com.vam.model.Criteria;
|
||||
|
||||
@@ -23,4 +24,10 @@ public interface BookMapper {
|
||||
/* 외국 카테고리 리스트 */
|
||||
public List<CateVO> getCateCode2();
|
||||
|
||||
/* 검색 대상 카테고리 리스트 */
|
||||
public String[] getCateList(Criteria cri);
|
||||
|
||||
/* 카테고리 정보(+검색대상 갯수) */
|
||||
public CateFilterDTO getCateInfo(Criteria cri);
|
||||
|
||||
}
|
||||
|
||||
56
VamPa_MySQL/src/main/java/com/vam/model/CateFilterDTO.java
Normal file
56
VamPa_MySQL/src/main/java/com/vam/model/CateFilterDTO.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package com.vam.model;
|
||||
|
||||
public class CateFilterDTO {
|
||||
|
||||
/* 카테고리 이름 */
|
||||
private String cateName;
|
||||
|
||||
/* 카테고리 넘버 */
|
||||
private String cateCode;;
|
||||
|
||||
/* 카테고리 상품 수 */
|
||||
private int cateCount;
|
||||
|
||||
/* 국내,국외 분류 */
|
||||
private String cateGroup;
|
||||
|
||||
public String getCateName() {
|
||||
return cateName;
|
||||
}
|
||||
|
||||
public void setCateName(String cateName) {
|
||||
this.cateName = cateName;
|
||||
}
|
||||
|
||||
public String getCateCode() {
|
||||
return cateCode;
|
||||
}
|
||||
|
||||
public void setCateCode(String cateCode) {
|
||||
this.cateCode = cateCode;
|
||||
this.cateGroup = cateCode.split("")[0];
|
||||
}
|
||||
|
||||
public int getCateCount() {
|
||||
return cateCount;
|
||||
}
|
||||
|
||||
public void setCateCount(int cateCount) {
|
||||
this.cateCount = cateCount;
|
||||
}
|
||||
|
||||
public String getCateGroup() {
|
||||
return cateGroup;
|
||||
}
|
||||
|
||||
public void setCateGroup(String cateGroup) {
|
||||
this.cateGroup = cateGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CateFilterDTO [cateName=" + cateName + ", cateCode=" + cateCode + ", cateCount=" + cateCount
|
||||
+ ", cateGroup=" + cateGroup + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -76,6 +76,71 @@
|
||||
select * from vam_bcate where cateCode > 200000 and cateCode < 300000
|
||||
]]>
|
||||
|
||||
</select>
|
||||
</select>
|
||||
|
||||
<!-- 검색 대상 카테고리 리스트 -->
|
||||
<select id="getCateList" resultType="String">
|
||||
|
||||
select distinct cateCode from vam_book where
|
||||
<foreach item="type" collection="typeArr">
|
||||
<choose>
|
||||
<when test="type == 'A'.toString()">
|
||||
<trim prefixOverrides="or">
|
||||
<foreach collection="authorArr" item="authorId">
|
||||
<trim prefix="or">
|
||||
authorId = #{authorId}
|
||||
</trim>
|
||||
</foreach>
|
||||
</trim>
|
||||
</when>
|
||||
<when test="type == 'T'.toString()">
|
||||
bookName like concat ('%', #{keyword}, '%')
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 카테고리 정보(+검색대상 갯수) -->
|
||||
<select id="getCateInfo" resultType="com.vam.model.CateFilterDTO">
|
||||
|
||||
select DISTINCT count(*) cateCount, a.cateCode,b.cateName from vam_book a left join vam_bcate b on a.cateCode = b.cateCode
|
||||
|
||||
where
|
||||
|
||||
<foreach item="type" collection="typeArr">
|
||||
<choose>
|
||||
<when test="type == 'A'.toString()">
|
||||
|
||||
<trim prefix="(" suffix=")" prefixOverrides="or">
|
||||
|
||||
<foreach collection="authorArr" item="authorId">
|
||||
|
||||
<trim prefix="or">
|
||||
|
||||
authorId = #{authorId}
|
||||
|
||||
</trim>
|
||||
|
||||
</foreach>
|
||||
|
||||
</trim>
|
||||
|
||||
and a.cateCode = #{cateCode}
|
||||
|
||||
</when>
|
||||
|
||||
<when test="type == 'T'.toString()">
|
||||
|
||||
bookName like concat ('%', #{keyword}, '%') and a.cateCode = #{cateCode}
|
||||
|
||||
</when>
|
||||
|
||||
</choose>
|
||||
</foreach>
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -1,14 +1,12 @@
|
||||
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.BookVO;
|
||||
import com.vam.model.CateFilterDTO;
|
||||
import com.vam.model.Criteria;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@@ -36,7 +34,7 @@ public class BookMapperTests {
|
||||
*/
|
||||
|
||||
/* 작가 id 리스트 요청 */
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void getAuthorId() {
|
||||
|
||||
@@ -51,6 +49,56 @@ public class BookMapperTests {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
/* 카테고리 리스트 얻기 */
|
||||
|
||||
@Test
|
||||
public void getCateListTest1() {
|
||||
|
||||
Criteria cri = new Criteria();
|
||||
|
||||
String type = "T";
|
||||
String keyword = "test";
|
||||
//String type = "A";
|
||||
//String keyword = "test";
|
||||
|
||||
cri.setType(type);
|
||||
cri.setKeyword(keyword);
|
||||
//cri.setAuthorArr(mapper.getAuthorIdList(keyword));
|
||||
|
||||
String[] cateList = mapper.getCateList(cri) ;
|
||||
for(String codeNum : cateList) {
|
||||
System.out.println("codeNum ::::: " + codeNum);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* 카테고리 정보 얻기 */
|
||||
@Test
|
||||
public void getCateInfoTest1() {
|
||||
|
||||
Criteria cri = new Criteria();
|
||||
|
||||
String type = "TC";
|
||||
String keyword = "test";
|
||||
String cateCode="104001";
|
||||
|
||||
cri.setType(type);
|
||||
cri.setKeyword(keyword);
|
||||
cri.setCateCode(cateCode);
|
||||
|
||||
mapper.getCateInfo(cri);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -76,6 +76,71 @@
|
||||
select * from vam_bcate where cateCode > 200000 and cateCode < 300000
|
||||
]]>
|
||||
|
||||
</select>
|
||||
</select>
|
||||
|
||||
<!-- 검색 대상 카테고리 리스트 -->
|
||||
<select id="getCateList" resultType="String">
|
||||
|
||||
select distinct cateCode from vam_book where
|
||||
<foreach item="type" collection="typeArr">
|
||||
<choose>
|
||||
<when test="type == 'A'.toString()">
|
||||
<trim prefixOverrides="or">
|
||||
<foreach collection="authorArr" item="authorId">
|
||||
<trim prefix="or">
|
||||
authorId = #{authorId}
|
||||
</trim>
|
||||
</foreach>
|
||||
</trim>
|
||||
</when>
|
||||
<when test="type == 'T'.toString()">
|
||||
bookName like concat ('%', #{keyword}, '%')
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 카테고리 정보(+검색대상 갯수) -->
|
||||
<select id="getCateInfo" resultType="com.vam.model.CateFilterDTO">
|
||||
|
||||
select DISTINCT count(*) cateCount, a.cateCode,b.cateName from vam_book a left join vam_bcate b on a.cateCode = b.cateCode
|
||||
|
||||
where
|
||||
|
||||
<foreach item="type" collection="typeArr">
|
||||
<choose>
|
||||
<when test="type == 'A'.toString()">
|
||||
|
||||
<trim prefix="(" suffix=")" prefixOverrides="or">
|
||||
|
||||
<foreach collection="authorArr" item="authorId">
|
||||
|
||||
<trim prefix="or">
|
||||
|
||||
authorId = #{authorId}
|
||||
|
||||
</trim>
|
||||
|
||||
</foreach>
|
||||
|
||||
</trim>
|
||||
|
||||
and a.cateCode = #{cateCode}
|
||||
|
||||
</when>
|
||||
|
||||
<when test="type == 'T'.toString()">
|
||||
|
||||
bookName like concat ('%', #{keyword}, '%') and a.cateCode = #{cateCode}
|
||||
|
||||
</when>
|
||||
|
||||
</choose>
|
||||
</foreach>
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user