<sql id="header">
select a.* from test a where 1=1
</sql>
<sql id="condition">
<if test="cardId != null">
and a.card_id = #{cardId}
</if>
<if test="keywordList !=null and keywordList.size >=0">
and(
<foreacn collection="keywordList" item="item" separator="and">
a.title like concat('%',#{item},'%')
</foreach>
)
</if>
<sql id="order">
order by a.weigth desc
</sql>
<select id ="" resultType="" parameterType="">
<include refid="header"/>
<include refid="condition"/>
<include refid="order"/>
</select>