以前写的,记录一下。。。
一、DxxJxx系统
1. 版本1(筛选条件单选)
<if test="searchKeywords != null and searchKeywords != ''">
<choose>
<when test="searchPosition == null or searchPosition == -1">
and (title like concat('%', #{searchKeywords}, '%') or content like concat('%',
#{searchKeywords}, '%'))
</when>
<when test="searchPosition == 0">
and title like concat('%', #{searchKeywords}, '%')
</when>
<when test="searchPosition == 1">
and content like concat('%', #{searchKeywords}, '%')
</when>
</choose>
</if>
2. 版本2(筛选条件改成可多选)
不知道抽什么风,单选要改成多选。好!满足你行了吧!!!
<if test="searchKeywords != null and searchKeywords != ''">
and
<choose>
<when test="searchPositionList != null and searchPositionList.size() > 0">
<choose>
<when test="searchPositionList.contains(0) and searchPositionList.contains(1)">
(title like concat('%', #{searchKeywords}, '%') or content like concat('%', #{searchKeywords},'%'))
</when>
<when test="searchPositionList.contains(0)">
title like concat('%', #{searchKeywords}, '%')
</when>
<when test="searchPositionList.contains(1)">
content like concat('%', #{searchKeywords}, '%')
</when>
</choose>
</when>
<otherwise>
(title like concat('%', #{searchKeywords}, '%') or content like concat('%', #{searchKeywords},'%'))
</otherwise>
</choose>
</if>