77 lines
2.1 KiB
XML
77 lines
2.1 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="(" suffix=") AND" 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">
|
|
authorId = #{authorId}
|
|
</trim>
|
|
</foreach>
|
|
</trim>
|
|
</when>
|
|
<when test="type == 'C'.toString()">
|
|
cateCode like '%' || #{cateCode} || '%'
|
|
</when>
|
|
<when test="type == 'T'.toString()">
|
|
bookName like '%' || #{keyword} || '%'
|
|
</when>
|
|
</choose>
|
|
</trim>
|
|
</foreach>
|
|
</trim>
|
|
|
|
</sql>
|
|
|
|
|
|
<!-- 상품 검색 -->
|
|
<select id="getGoodsList" resultType="com.vam.model.BookVO">
|
|
|
|
<![CDATA[
|
|
select * from(
|
|
select /*+INDEX_DESC(vam_book SYS_C008227)*/ rownum as rn, bookId, bookName,
|
|
(select authorName from vam_author where vam_book.authorId = vam_author.authorId) authorName, authorId,
|
|
(select cateName from vam_bcate where vam_book.cateCode = vam_bcate.cateCode) cateName,cateCode, publisher, publeYear, bookPrice,bookDiscount
|
|
from vam_book
|
|
where
|
|
]]>
|
|
|
|
<include refid="criteria"></include>
|
|
|
|
<![CDATA[
|
|
rownum <= #{pageNum} * #{amount}
|
|
)
|
|
where rn > (#{pageNum} -1) * #{amount}
|
|
]]>
|
|
|
|
</select>
|
|
|
|
<!-- 상품 총 개수 -->
|
|
<select id="goodsGetTotal" resultType="int">
|
|
|
|
select count(*) from vam_book
|
|
where
|
|
<include refid="criteria"></include>
|
|
bookId >0
|
|
|
|
</select>
|
|
|
|
<!-- 작가 id 리스트 요청 -->
|
|
<select id="getAuthorIdList" resultType="String">
|
|
|
|
select authorid from vam_author where authorName like '%' || #{keyword} || '%'
|
|
|
|
</select>
|
|
|
|
|
|
</mapper> |