<?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 AS rt
           SET expire_at = tt.expire_at,
               update_dt = CURRENT_TIMESTAMP
          FROM (
                <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>
            ) AS tt
        WHERE rt.host_id = tt.host_id
          AND rt.host_ip = tt.host_ip
    </update>

</mapper>
