时间:2022-07-27 11:15:50 | 栏目:JAVA代码 | 点击:次
在业务变更需支持多条件查询,在改动最小的情况下,实现方式就是只改mapper.xml,这时,可让前端逗号分隔传参
<if test="paramXXX!= null and paramXXX!= ''"> and t.paramXXX in <foreach item="item" index="index" collection="paramXXX.split(',')" open="(" separator="," close=")"> #{item} </foreach> </if>
select id,name from user where <if test="ids!=null and ids!=''"> id in <foreach collection="ids.split(',')" item="item" index="index" open="(" separator="," close=")"> #{item} </foreach> </if>