<?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
           SET expire_at = src.expire_at,
               update_dt = CURRENT_TIMESTAMP
          FROM sj_server_node AS dest
               JOIN (
                 <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 src ON (dest.host_id = src.host_id AND dest.host_ip = src.host_ip)
    </update>

</mapper>
