xml使用foreach

 

复制代码
public class OrderScenicBindParam implements Serializable {
    private Long orgId;
    private List<Long> parkList;

    public Long getOrgId() {
        return orgId;
    }

    public void setOrgId(Long orgId) {
        this.orgId = orgId;
    }

    public List<Long> getParkList() {
        return parkList;
    }

    public void setParkList(List<Long> parkList) {
        this.parkList = parkList;
    }
}
复制代码

List<Long>类型的入参 parkList

    <select id="selectScenicCodeByParkList" parameterType="cn.galasys.clota.ota.entity.OrderScenicBindParam" resultType="Long">
        select distinct code from order_scenic_bind_rule where is_deleted = 'false' and status = 'true' and org_id = #{orgId}
        and (
        <foreach collection="parkList" item="parkId" index="index" separator="or">
            scenic_id like concat('%',#{parkId},'%')
        </foreach>
        )
    </select>

String类型的入参 visitorId(1,2,3,4),使用 split(,)拆分成数组

复制代码
    <select id="selectBlockGuestList" parameterType="cn.galasys.clota.ota.vo.hotel.HotelParam" resultType="cn.galasys.clota.ota.vo.hotel.BlockGuestDto">
        SELECT ov.visitor_type as visitorType,ov.visitor_name as visitorName,ov.document_info as documentInfo,ov.phone_number as phoneNumber,
        ov.document_type as documentType,ov.document_code as documentCode,ov.gender,ov.age_qualifying_code as ageQualifyingCode,ov.guest_type as guestType
        FROM order_visitor ov
        WHERE ov.order_id = #{orderId} AND ov.visitor_type = #{visitorType} AND ov.is_deleted = 'false'
        <if test="visitorId != null and visitorId != ''">
            and ov.id in
            <foreach item="visId" collection="visitorId.split(',')" open="(" separator="," close=")" index="index" >
                #{visId}
            </foreach>
        </if>
    </select>
复制代码

 

参考:https://blog.csdn.net/qqqwwweeerasd/article/details/122990644

posted @   DHaiLin  阅读(141)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
历史上的今天:
2021-03-10 Java_Callable<V>的基本使用
2021-03-10 java_锁_synchronized与Lock的区别
2021-03-10 java_阻塞队列(FIFO先进先出)
点击右上角即可分享
微信分享提示