Mybatis mapper配置文件传入数组参数

段干河
2023-12-01
<select id="yktestOrder" resultType="com.yuxun.fantuan.security.entity.User">
        select
        u.id,
        u.username
        FROM
        user u
        WHERE
        1 = 1
        <if test="null != ids and ids.size > 0">
        AND u.id IN
        <foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
            #{item}
        </foreach>
            order by field(u.id,
            <foreach item="item" index="index" collection="ids" separator=",">
                #{item}
            </foreach>
            )
        </if>
    </select>

 

 类似资料: