<?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.m2pool.lease.mapper.LeaseGpuConfigMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeaseGpuConfig">
        <id column="id" property="id" />
        <result column="brand" property="brand" />
        <result column="name" property="name" />
        <result column="status" property="status" />
        <result column="memory" property="memory" />
        <result column="power_dissipation" property="powerDissipation" />
        <result column="del" property="del" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, brand, name, status, memory, power_dissipation, del
    </sql>
    <insert id="insertOrUpdateBatchByGpuInfo">
        insert into lease_gpu_config ( name, algorithm,coin)
        values
        <foreach item="item" index="index" collection="list" separator=",">
            (#{item.model}, #{item.algorithm},'')
        </foreach>
        ON DUPLICATE KEY UPDATE
        name = VALUES(`name`),
        `algorithm` = VALUES(`algorithm`),
        coin = VALUES(coin)
    </insert>
    <insert id="insertOrUpdateBatchByEntity">
        insert into lease_gpu_config ( name, algorithm, power_dissipation,hashrate,month_income)
        values
        <foreach item="item" index="index" collection="list" separator=",">
            (#{item.name}, #{item.algorithm}, #{item.powerDissipation},#{item.hashrate},#{item.monthIncome})
        </foreach>
        ON DUPLICATE KEY UPDATE
        name = VALUES(`name`),
        `algorithm` = VALUES(`algorithm`),
        power_dissipation = VALUES(power_dissipation),
        hashrate = VALUES(hashrate),
        month_income = VALUES(month_income)
    </insert>


</mapper>
