<if test="userIds != null and userIds.size > 0"> AND user_id in <foreach collection="userIds" item="userId" open="(" separator="," close=")"> #{userId} </foreach> </if>