🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
``` <sql id="query_user_where"> <if test="user != null"> <if test="user.username != null and user.username != ''"> AND username like '%${user.username}%' </if> </if> <if test="ids != null and ids.size() > 0"> <!-- collection:指定输入的集合参数的参数名称 --> <!-- item:声明集合参数中的元素变量名 --> <!-- open:集合遍历时,需要拼接到遍历sql语句的前面 --> <!-- close:集合遍历时,需要拼接到遍历sql语句的后面 --> <!-- separator:集合遍历时,需要拼接到遍历sql语句之间的分隔符号 --> <foreach collection="ids" item="id" open=" AND id IN ( " close=" ) " separator=","> #{id} </foreach> </if> </sql> ```