<?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.neusoft.smart.pos.ota.persistent.mapper.DeviceUpgradeHistoryMapperExt">
    <resultMap id="LastUpdateTimeResultMap" type="com.neusoft.smart.pos.ota.persistent.domain.DeviceUpgradeHistoryExt">
        <result column="device_id" jdbcType="INTEGER" property="deviceId"/>
        <result column="last_update_time" jdbcType="TIMESTAMP" property="lastUpdateTime"/>
    </resultMap>

    <select id="selectLastUpdateTimeByDeviceIds" resultMap="LastUpdateTimeResultMap">
        SELECT
        duh.device_id,
        max(duh.update_time) last_update_time
        FROM
        device_upgrade_history duh
        WHERE duh.device_id IN
        <foreach item="deviceId" collection="deviceIds" open="(" separator="," close=")">
            #{deviceId,jdbcType=INTEGER}
        </foreach>
        GROUP BY duh.device_id
    </select>
</mapper>