<select id="listByIds" resultType="org.jeecg.modules.gz.system.entity.SysUser">
select id,userName,realName
from sys_user
where id in
<choose>
<when test="ids!=null and ids.size()>0">
<foreach collection="ids" open="(" close=")" item="item" separator=",">
#{item}
</foreach>
</when>
<otherwise>
('')
</otherwise>
</choose>
</select>
用size()判断是否是空集合,是空集合的话就需要拼接成 in(’’) 的格式,否则会是in(),查询就出错了。
这个搞法用了很多次,过个春节再用,又想不起来了,记录下来备忘