<?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.water.mapper.BasePumpMapper">

    <resultMap type="com.tofly.water.entity.BasePump" id="BasePumpMap">
        <result property="id" column="ID" jdbcType="INTEGER"/>
        <result property="name" column="NAME" jdbcType="VARCHAR"/>
        <result property="category" column="CATEGORY" jdbcType="INTEGER"/>
        <result property="grouping" column="GROUPING" jdbcType="VARCHAR"/>
        <result property="code" column="CODE" jdbcType="VARCHAR"/>
        <result property="support" column="SUPPORT" jdbcType="VARCHAR"/>
        <result property="scale" column="SCALE" jdbcType="VARCHAR"/>
        <result property="ascription" column="ASCRIPTION" jdbcType="VARCHAR"/>
        <result property="installationPosition" column="INSTALLATION_POSITION" jdbcType="VARCHAR"/>
        <result property="coordinate" column="COORDINATE" jdbcType="VARCHAR"/>
        <result property="relativeRange" column="RELATIVE_RANGE" jdbcType="VARCHAR"/>
        <result property="address" column="ADDRESS" jdbcType="VARCHAR"/>
        <result property="remark" column="REMARK" jdbcType="VARCHAR"/>
        <result property="investmentDate" column="INVESTMENT_DATE" jdbcType="TIMESTAMP"/>
        <result property="managementUnit" column="MANAGEMENT_UNIT" jdbcType="INTEGER"/>
        <result property="model" column="MODEL" jdbcType="VARCHAR"/>
        <result property="waterCapacity" column="WATER_CAPACITY" jdbcType="VARCHAR"/>
        <result property="supplierSimple" column="SUPPLIER_SIMPLE" jdbcType="VARCHAR"/>
        <result property="supplierDetail" column="SUPPLIER_DETAIL" jdbcType="VARCHAR"/>
        <result property="supplierPhone" column="SUPPLIER_PHONE" jdbcType="VARCHAR"/>
        <result property="annex" column="ANNEX" jdbcType="VARCHAR"/>
        <result property="sort" column="SORT" jdbcType="INTEGER"/>
        <result property="deleted" column="DELETED" jdbcType="VARCHAR"/>
        <result property="createdUser" column="CREATED_USER" jdbcType="INTEGER"/>
        <result property="createdTime" column="CREATED_TIME" jdbcType="TIMESTAMP"/>
        <result property="updatedUser" column="UPDATED_USER" jdbcType="INTEGER"/>
        <result property="updatedTime" column="UPDATED_TIME" jdbcType="TIMESTAMP"/>
        <association property="createdUserName" column="CREATED_USER"
                     select="com.tofly.baseapi.mapper.ToflyCodeCommonMapper.getUserName"/>
        <association property="updatedUserName" column="UPDATED_USER"
                     select="com.tofly.baseapi.mapper.ToflyCodeCommonMapper.getUserName"/>
    </resultMap>

    <!-- 批量插入 -->
    <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
        insert into TF_BASE_PUMP(NAME, CATEGORY, GROUPING, CODE, SUPPORT, SCALE, ASCRIPTION,
        INSTALLATION_POSITION, COORDINATE, ADDRESS, REMARK, INVESTMENT_DATE, MANAGEMENT_UNIT, MODEL, WATER_CAPACITY,
        SUPPLIER_SIMPLE, SUPPLIER_DETAIL, SUPPLIER_PHONE, ANNEX, SORT, DELETED, CREATED_USER, CREATED_TIME,
        UPDATED_USER, UPDATED_TIME)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.name}, #{entity.category}, #{entity.grouping}, #{entity.code}, #{entity.support}, #{entity.scale},
            #{entity.ascription}, #{entity.installationPosition}, #{entity.coordinate}, #{entity.address},
            #{entity.remark}, #{entity.investmentDate}, #{entity.managementUnit}, #{entity.model},
            #{entity.waterCapacity}, #{entity.supplierSimple}, #{entity.supplierDetail}, #{entity.supplierPhone},
            #{entity.annex}, #{entity.sort}, #{entity.deleted}, #{entity.createdUser}, #{entity.createdTime},
            #{entity.updatedUser}, #{entity.updatedTime})
        </foreach>
    </insert>
    <!-- 批量插入或按主键更新 -->
    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
        insert into TF_BASE_PUMP(NAME, CATEGORY, GROUPING, CODE, SUPPORT, SCALE, ASCRIPTION,
        INSTALLATION_POSITION, COORDINATE, ADDRESS, REMARK, INVESTMENT_DATE, MANAGEMENT_UNIT, MODEL, WATER_CAPACITY,
        SUPPLIER_SIMPLE, SUPPLIER_DETAIL, SUPPLIER_PHONE, ANNEX, SORT, DELETED, CREATED_USER, CREATED_TIME,
        UPDATED_USER, UPDATED_TIME)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.name}, #{entity.category}, #{entity.grouping}, #{entity.code}, #{entity.support}, #{entity.scale},
            #{entity.ascription}, #{entity.installationPosition}, #{entity.coordinate}, #{entity.address},
            #{entity.remark}, #{entity.investmentDate}, #{entity.managementUnit}, #{entity.model},
            #{entity.waterCapacity}, #{entity.supplierSimple}, #{entity.supplierDetail}, #{entity.supplierPhone},
            #{entity.annex}, #{entity.sort}, #{entity.deleted}, #{entity.createdUser}, #{entity.createdTime},
            #{entity.updatedUser}, #{entity.updatedTime})
        </foreach>
        on duplicate key update
        NAME = values(NAME) , CATEGORY = values(CATEGORY) , GROUPING = values(GROUPING) , CODE = values(CODE) , SUPPORT
        = values(SUPPORT) , SCALE = values(SCALE) , ASCRIPTION = values(ASCRIPTION) , INSTALLATION_POSITION =
        values(INSTALLATION_POSITION) , COORDINATE = values(COORDINATE) , ADDRESS = values(ADDRESS) , REMARK =
        values(REMARK) , INVESTMENT_DATE = values(INVESTMENT_DATE) , MANAGEMENT_UNIT = values(MANAGEMENT_UNIT) , MODEL =
        values(MODEL) , WATER_CAPACITY = values(WATER_CAPACITY) , SUPPLIER_SIMPLE = values(SUPPLIER_SIMPLE) ,
        SUPPLIER_DETAIL = values(SUPPLIER_DETAIL) , SUPPLIER_PHONE = values(SUPPLIER_PHONE) , ANNEX = values(ANNEX) ,
        SORT = values(SORT) , DELETED = values(DELETED) , CREATED_USER = values(CREATED_USER) , CREATED_TIME =
        values(CREATED_TIME) , UPDATED_USER = values(UPDATED_USER) , UPDATED_TIME = values(UPDATED_TIME)
    </insert>

</mapper>

