MyBatis DAO层有多个参数的处理

来源:互联网 发布:淘宝上怎么购买呼死你 编辑:程序博客网 时间:2024/04/19 20:36
<!-- query multi param filter -->
<sql id="query_multi_param_filter">
<if test='_parameter.get("0").id!=null and _parameter.get("0").id!=""'>
id = #{0.id},
</if>
<if test='_parameter.get("0").title!=null and _parameter.get("0").title!=""'>
and title = #{0.title},
</if>
<if test='_parameter.get("0").sellPoint!=null and _parameter.get("0").sellPoint!=""'>
and sell_point like #{0.sellPoint},
</if>
<if test='_parameter.get("0").price!=null'>
and price = #{price},
</if>
<if test='_parameter.get("0").num!=null'>
and num = #{0.num},
</if>
<if test='_parameter.get("0").barcode!=null and _parameter.get("0").barcode!=""'>
and barcode = #{0.barcode},
</if>
<if test='_parameter.get("0").categoryId!=null and _parameter.get("0").categoryId!=""'>
and category_id = #{0.categoryId},
</if>
<if test='_parameter.get("0").status!=null'>
and status = #{0.status}
</if>

</sql>


_parameter.get("0")可以获取对应的参数,0为用@Param("0")注解的参数

注意: _parameter.get("0")中0必须用双引号,外边用单引号



原创粉丝点击