<?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.tofly.spire.mapper.SpireGateMapper">

    <resultMap type="com.tofly.spire.entity.SpireGate" id="SpireGateMap">
        <result property="id" column="ID" jdbcType="INTEGER"/>
        <result property="sn" column="SN" jdbcType="VARCHAR"/>
        <result property="flag" column="FLAG" jdbcType="VARCHAR"/>
        <result property="status" column="STATUS" jdbcType="VARCHAR"/>
        <result property="uploadTime" column="UPLOAD_TIME" jdbcType="TIMESTAMP"/>
        <result property="createTime" column="CREATE_TIME" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="UPDATE_TIME" jdbcType="TIMESTAMP"/>
        <result property="result" column="RESULT" jdbcType="VARCHAR"/>
    </resultMap>

    <!-- 批量插入 -->
    <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
        insert into SPIRE_GATE(SN, FLAG, STATUS, UPLOAD_TIME, CREATE_TIME, UPDATE_TIME, RESULT)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.sn}, #{entity.flag}, #{entity.status}, #{entity.uploadTime}, #{entity.createTime},
            #{entity.updateTime}, #{entity.result})
        </foreach>
    </insert>
    <!-- 批量插入或按主键更新 -->
    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
        insert into SPIRE_GATE(SN, FLAG, STATUS, UPLOAD_TIME, CREATE_TIME, UPDATE_TIME, RESULT)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.sn}, #{entity.flag}, #{entity.status}, #{entity.uploadTime}, #{entity.createTime},
            #{entity.updateTime}, #{entity.result})
        </foreach>
        on duplicate key update
        SN = values(SN) , FLAG = values(FLAG) , STATUS = values(STATUS) , UPLOAD_TIME = values(UPLOAD_TIME) ,
        CREATE_TIME = values(CREATE_TIME) , UPDATE_TIME = values(UPDATE_TIME) , RESULT = values(RESULT)
    </insert>

</mapper>

