172 lines
4.6 KiB
XML
172 lines
4.6 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE mapper
|
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.vam.mapper.BookMapper">
|
|
|
|
<!-- criteria(검색조건) -->
|
|
<sql id="criteria">
|
|
|
|
<trim prefix="where (" suffix=")" prefixOverrides="AND">
|
|
<foreach item="type" collection="typeArr">
|
|
<trim prefix="AND">
|
|
<choose>
|
|
<when test="type == 'A'.toString()">
|
|
<trim prefixOverrides="or">
|
|
<foreach collection="authorArr" item="authorId">
|
|
<trim prefix="or">
|
|
a.authorId = #{authorId}
|
|
</trim>
|
|
</foreach>
|
|
</trim>
|
|
</when>
|
|
<when test="type == 'C'.toString()">
|
|
a.cateCode like concat ('%', #{cateCode}, '%')
|
|
</when>
|
|
<when test="type == 'T'.toString()">
|
|
bookName like concat ('%', #{keyword}, '%')
|
|
</when>
|
|
</choose>
|
|
</trim>
|
|
</foreach>
|
|
</trim>
|
|
|
|
</sql>
|
|
|
|
<!-- 상품 검색 -->
|
|
<select id="getGoodsList" resultType="com.vam.model.BookVO">
|
|
|
|
select bookId, bookName, b.authorName, a.authorId, c.cateName, a.cateCode, publisher, publeYear, bookPrice, bookDiscount
|
|
from vam_book a left outer join vam_author b on a.authorId = b.authorId
|
|
left outer join vam_bcate c on a.cateCode = c.cateCode
|
|
<include refid="criteria"></include>
|
|
order by bookId desc
|
|
limit #{skip}, #{amount}
|
|
|
|
</select>
|
|
|
|
<!-- 상품 총 개수 -->
|
|
<select id="goodsGetTotal" resultType="int">
|
|
|
|
select count(*) from vam_book a
|
|
|
|
<include refid="criteria"></include>
|
|
|
|
</select>
|
|
|
|
<!-- 작가 id 리스트 요청 -->
|
|
<select id="getAuthorIdList" resultType="String">
|
|
|
|
select authorid from vam_author where authorname like concat ('%', #{keyword}, '%')
|
|
|
|
</select>
|
|
|
|
<!-- 국내 카테고리 리스트 -->
|
|
<select id="getCateCode1" resultType="com.vam.model.CateVO">
|
|
|
|
<![CDATA[
|
|
select * from vam_bcate where cateCode > 100000 and cateCode < 200000
|
|
]]>
|
|
</select>
|
|
|
|
<!-- 외국 카테고리 리스트 -->
|
|
<select id="getCateCode2" resultType="com.vam.model.CateVO">
|
|
|
|
<![CDATA[
|
|
select * from vam_bcate where cateCode > 200000 and cateCode < 300000
|
|
]]>
|
|
|
|
</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>
|
|
|
|
<!-- 상품 정보 -->
|
|
<select id="getGoodsInfo" resultType="com.vam.model.BookVO">
|
|
|
|
select a.BOOKID, a.BOOKNAME, a.AUTHORID, b.AUTHORNAME, a.PUBLEYEAR, a.PUBLISHER, a.CATECODE, c.CATENAME, a.BOOKPRICE, a.BOOKSTOCK, a.BOOKDISCOUNT, a.BOOKINTRO, a.BOOKCONTENTS
|
|
from vam_book a left outer join vam_author b on a.authorId = b.authorId
|
|
left outer join vam_bcate c on a.catecode = c.catecode
|
|
where bookid = ${bookId}
|
|
|
|
</select>
|
|
|
|
<select id="getBookIdName" resultType="com.vam.model.BookVO">
|
|
|
|
select bookId, bookName from vam_book
|
|
where bookId = #{bookId}
|
|
|
|
|
|
</select>
|
|
|
|
<select id="likeSelect" resultType="com.vam.model.SelectDTO">
|
|
|
|
select bookId, bookName, ratingAvg, (select cateName from vam_bcate where vam_book.cateCode = vam_bcate.cateCode) as cateName
|
|
from vam_book
|
|
order by ratingAvg desc limit 8
|
|
|
|
</select>
|
|
|
|
|
|
</mapper> |