<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.aizuda.snailjob.template.datasource.persistence.mapper.ServerNodeMapper">

    <update id="updateBatchExpireAt" parameterType="java.util.List">
        UPDATE sj_server_node rt,
               (
                    <foreach collection="list" item="item" index="index" separator="UNION ALL">
                        SELECT
                            #{item.hostId}      AS host_id,
                            #{item.hostIp}      AS host_ip,
                            #{item.expireAt}    AS expire_at
                    </foreach>
               ) tt
           SET rt.expire_at = tt.expire_at
         WHERE rt.host_id = tt.host_id
           AND rt.host_ip = tt.host_ip
    </update>

</mapper>
