[Spring][쇼핑몰 프로젝트][31] 검색 구현(조건 검색 적용 -2)
https://kimvampa.tistory.com/246
This commit is contained in:
@@ -6,9 +6,31 @@
|
||||
|
||||
<!-- criteria(검색조건) -->
|
||||
<sql id="criteria">
|
||||
<if test="keyword != null">
|
||||
bookName like '%' || #{keyword} || '%' and
|
||||
</if>
|
||||
|
||||
<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>
|
||||
|
||||
|
||||
|
||||
@@ -6,9 +6,31 @@
|
||||
|
||||
<!-- criteria(검색조건) -->
|
||||
<sql id="criteria">
|
||||
<if test="keyword != null">
|
||||
bookName like '%' || #{keyword} || '%' and
|
||||
</if>
|
||||
|
||||
<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>
|
||||
|
||||
|
||||
|
||||
@@ -6,9 +6,31 @@
|
||||
|
||||
<!-- criteria(검색조건) -->
|
||||
<sql id="criteria">
|
||||
<if test="keyword != null">
|
||||
where (bookName like concat ('%', #{keyword}, '%'))
|
||||
</if>
|
||||
|
||||
<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>
|
||||
|
||||
<!-- 상품 검색 -->
|
||||
|
||||
@@ -6,9 +6,31 @@
|
||||
|
||||
<!-- criteria(검색조건) -->
|
||||
<sql id="criteria">
|
||||
<if test="keyword != null">
|
||||
where (bookName like concat ('%', #{keyword}, '%'))
|
||||
</if>
|
||||
|
||||
<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>
|
||||
|
||||
<!-- 상품 검색 -->
|
||||
|
||||
Reference in New Issue
Block a user