<?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.bailuntec.mapper.DcMidCostFirstMapper">
    <resultMap id="BaseResultMap" type="com.bailuntec.domain.entity.DcMidCostFirst">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="cost_first" jdbcType="DECIMAL" property="costFirst"/>
        <result column="bailun_sku" jdbcType="VARCHAR" property="bailunSku"/>
        <result column="warehouse_code" jdbcType="VARCHAR" property="warehouseCode"/>
        <result column="company_id" jdbcType="INTEGER" property="companyId"/>
        <result column="has_calculation" jdbcType="BIT" property="hasCalculation"/>
        <result column="cost_count" jdbcType="INTEGER" property="costCount"/>
        <result column="has_config" jdbcType="BIT" property="hasConfig"/>
    </resultMap>
    <sql id="Example_Where_Clause">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        <where>
            <foreach collection="oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
                                             separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Update_By_Example_Where_Clause">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        <where>
            <foreach collection="example.oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
                                             separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Base_Column_List">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        id, cost_first, bailun_sku, warehouse_code, company_id, has_calculation, cost_count,
        has_config
    </sql>
    <select id="selectByExample" parameterType="com.bailuntec.domain.example.DcMidCostFirstExample"
            resultMap="BaseResultMap">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        select
        <if test="distinct">
            distinct
        </if>
        <include refid="Base_Column_List"/>
        from dc_mid_cost_first
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
        <if test="rows != null">
            <if test="offset != null">
                limit ${offset}, ${rows}
            </if>
            <if test="offset == null">
                limit ${rows}
            </if>
        </if>
    </select>
    <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        select
        <include refid="Base_Column_List"/>
        from dc_mid_cost_first
        where id = #{id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        delete from dc_mid_cost_first
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <delete id="deleteByExample" parameterType="com.bailuntec.domain.example.DcMidCostFirstExample">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        delete from dc_mid_cost_first
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </delete>
    <insert id="insert" parameterType="com.bailuntec.domain.entity.DcMidCostFirst">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        insert into dc_mid_cost_first (id, cost_first, bailun_sku,
        warehouse_code, company_id, has_calculation,
        cost_count, has_config)
        values (#{id,jdbcType=INTEGER}, #{costFirst,jdbcType=DECIMAL}, #{bailunSku,jdbcType=VARCHAR},
        #{warehouseCode,jdbcType=VARCHAR}, #{companyId,jdbcType=INTEGER}, #{hasCalculation,jdbcType=BIT},
        #{costCount,jdbcType=INTEGER}, #{hasConfig,jdbcType=BIT})
    </insert>
    <insert id="insertSelective" parameterType="com.bailuntec.domain.entity.DcMidCostFirst">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        insert into dc_mid_cost_first
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="costFirst != null">
                cost_first,
            </if>
            <if test="bailunSku != null">
                bailun_sku,
            </if>
            <if test="warehouseCode != null">
                warehouse_code,
            </if>
            <if test="companyId != null">
                company_id,
            </if>
            <if test="hasCalculation != null">
                has_calculation,
            </if>
            <if test="costCount != null">
                cost_count,
            </if>
            <if test="hasConfig != null">
                has_config,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="costFirst != null">
                #{costFirst,jdbcType=DECIMAL},
            </if>
            <if test="bailunSku != null">
                #{bailunSku,jdbcType=VARCHAR},
            </if>
            <if test="warehouseCode != null">
                #{warehouseCode,jdbcType=VARCHAR},
            </if>
            <if test="companyId != null">
                #{companyId,jdbcType=INTEGER},
            </if>
            <if test="hasCalculation != null">
                #{hasCalculation,jdbcType=BIT},
            </if>
            <if test="costCount != null">
                #{costCount,jdbcType=INTEGER},
            </if>
            <if test="hasConfig != null">
                #{hasConfig,jdbcType=BIT},
            </if>
        </trim>
    </insert>
    <select id="countByExample" parameterType="com.bailuntec.domain.example.DcMidCostFirstExample"
            resultType="java.lang.Long">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        select count(*) from dc_mid_cost_first
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </select>
    <update id="updateByExampleSelective" parameterType="map">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update dc_mid_cost_first
        <set>
            <if test="record.id != null">
                id = #{record.id,jdbcType=INTEGER},
            </if>
            <if test="record.costFirst != null">
                cost_first = #{record.costFirst,jdbcType=DECIMAL},
            </if>
            <if test="record.bailunSku != null">
                bailun_sku = #{record.bailunSku,jdbcType=VARCHAR},
            </if>
            <if test="record.warehouseCode != null">
                warehouse_code = #{record.warehouseCode,jdbcType=VARCHAR},
            </if>
            <if test="record.companyId != null">
                company_id = #{record.companyId,jdbcType=INTEGER},
            </if>
            <if test="record.hasCalculation != null">
                has_calculation = #{record.hasCalculation,jdbcType=BIT},
            </if>
            <if test="record.costCount != null">
                cost_count = #{record.costCount,jdbcType=INTEGER},
            </if>
            <if test="record.hasConfig != null">
                has_config = #{record.hasConfig,jdbcType=BIT},
            </if>
        </set>
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByExample" parameterType="map">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update dc_mid_cost_first
        set id = #{record.id,jdbcType=INTEGER},
        cost_first = #{record.costFirst,jdbcType=DECIMAL},
        bailun_sku = #{record.bailunSku,jdbcType=VARCHAR},
        warehouse_code = #{record.warehouseCode,jdbcType=VARCHAR},
        company_id = #{record.companyId,jdbcType=INTEGER},
        has_calculation = #{record.hasCalculation,jdbcType=BIT},
        cost_count = #{record.costCount,jdbcType=INTEGER},
        has_config = #{record.hasConfig,jdbcType=BIT}
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.bailuntec.domain.entity.DcMidCostFirst">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update dc_mid_cost_first
        <set>
            <if test="costFirst != null">
                cost_first = #{costFirst,jdbcType=DECIMAL},
            </if>
            <if test="bailunSku != null">
                bailun_sku = #{bailunSku,jdbcType=VARCHAR},
            </if>
            <if test="warehouseCode != null">
                warehouse_code = #{warehouseCode,jdbcType=VARCHAR},
            </if>
            <if test="companyId != null">
                company_id = #{companyId,jdbcType=INTEGER},
            </if>
            <if test="hasCalculation != null">
                has_calculation = #{hasCalculation,jdbcType=BIT},
            </if>
            <if test="costCount != null">
                cost_count = #{costCount,jdbcType=INTEGER},
            </if>
            <if test="hasConfig != null">
                has_config = #{hasConfig,jdbcType=BIT},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.bailuntec.domain.entity.DcMidCostFirst">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update dc_mid_cost_first
        set cost_first = #{costFirst,jdbcType=DECIMAL},
        bailun_sku = #{bailunSku,jdbcType=VARCHAR},
        warehouse_code = #{warehouseCode,jdbcType=VARCHAR},
        company_id = #{companyId,jdbcType=INTEGER},
        has_calculation = #{hasCalculation,jdbcType=BIT},
        cost_count = #{costCount,jdbcType=INTEGER},
        has_config = #{hasConfig,jdbcType=BIT}
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="upsertBatch">

        insert into dc_mid_cost_first
        (
        cost_first,
        bailun_sku,
        warehouse_code,
        company_id,
        has_calculation,
        cost_count,
        has_config)
        values
        <foreach collection="lists" item="item" index="index" separator=",">
            (
            #{item.costFirst,jdbcType=DECIMAL},
            #{item.bailunSku,jdbcType=VARCHAR},
            #{item.warehouseCode,jdbcType=VARCHAR},
            #{item.companyId,jdbcType=INTEGER},
            #{item.hasCalculation,jdbcType=BIT},
            #{item.costCount,jdbcType=INTEGER},
            #{item.hasConfig,jdbcType=BIT}
            )
        </foreach>
        on duplicate key update
        cost_first = values(cost_first),
        bailun_sku = values(bailun_sku),
        warehouse_code = values(warehouse_code),
        company_id = values(company_id),
        has_calculation = values(has_calculation),
        cost_count = values(cost_count),
        has_config = values(has_config)
    </update>

    <insert id="upsertSelective" parameterType="com.bailuntec.domain.entity.DcMidCostFirst">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
          @project https://github.com/itfsw/mybatis-generator-plugin
        -->
        insert into dc_mid_cost_first
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="costFirst != null">
                cost_first,
            </if>
            <if test="bailunSku != null">
                bailun_sku,
            </if>
            <if test="warehouseCode != null">
                warehouse_code,
            </if>
            <if test="companyId != null">
                company_id,
            </if>
            <if test="hasCalculation != null">
                has_calculation,
            </if>
            <if test="costCount != null">
                cost_count,
            </if>
            <if test="hasConfig != null">
                has_config,
            </if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="costFirst != null">
                #{costFirst,jdbcType=DECIMAL},
            </if>
            <if test="bailunSku != null">
                #{bailunSku,jdbcType=VARCHAR},
            </if>
            <if test="warehouseCode != null">
                #{warehouseCode,jdbcType=VARCHAR},
            </if>
            <if test="companyId != null">
                #{companyId,jdbcType=INTEGER},
            </if>
            <if test="hasCalculation != null">
                #{hasCalculation,jdbcType=BIT},
            </if>
            <if test="costCount != null">
                #{costCount,jdbcType=INTEGER},
            </if>
            <if test="hasConfig != null">
                #{hasConfig,jdbcType=BIT},
            </if>
        </trim>
        on duplicate key update
        <trim suffixOverrides=",">
            <if test="id != null">
                id = #{id,jdbcType=INTEGER},
            </if>
            <if test="costFirst != null">
                cost_first = #{costFirst,jdbcType=DECIMAL},
            </if>
            <if test="bailunSku != null">
                bailun_sku = #{bailunSku,jdbcType=VARCHAR},
            </if>
            <if test="warehouseCode != null">
                warehouse_code = #{warehouseCode,jdbcType=VARCHAR},
            </if>
            <if test="companyId != null">
                company_id = #{companyId,jdbcType=INTEGER},
            </if>
            <if test="hasCalculation != null">
                has_calculation = #{hasCalculation,jdbcType=BIT},
            </if>
            <if test="costCount != null">
                cost_count = #{costCount,jdbcType=INTEGER},
            </if>
            <if test="hasConfig != null">
                has_config = #{hasConfig,jdbcType=BIT},
            </if>
        </trim>
    </insert>
    <insert id="upsert" parameterType="com.bailuntec.domain.entity.DcMidCostFirst">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
          @project https://github.com/itfsw/mybatis-generator-plugin
        -->
        insert into dc_mid_cost_first
        (id, cost_first, bailun_sku, warehouse_code, company_id, has_calculation, cost_count,
        has_config)
        values
        (#{id,jdbcType=INTEGER}, #{costFirst,jdbcType=DECIMAL}, #{bailunSku,jdbcType=VARCHAR},
        #{warehouseCode,jdbcType=VARCHAR}, #{companyId,jdbcType=INTEGER}, #{hasCalculation,jdbcType=BIT},
        #{costCount,jdbcType=INTEGER}, #{hasConfig,jdbcType=BIT})
        on duplicate key update
        id = #{id,jdbcType=INTEGER},
        cost_first = #{costFirst,jdbcType=DECIMAL},
        bailun_sku = #{bailunSku,jdbcType=VARCHAR},
        warehouse_code = #{warehouseCode,jdbcType=VARCHAR},
        company_id = #{companyId,jdbcType=INTEGER},
        has_calculation = #{hasCalculation,jdbcType=BIT},
        cost_count = #{costCount,jdbcType=INTEGER},
        has_config = #{hasConfig,jdbcType=BIT}
    </insert>
    <select id="selectOneByExample" parameterType="com.bailuntec.domain.example.DcMidCostFirstExample"
            resultMap="BaseResultMap">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
          @project https://github.com/itfsw/mybatis-generator-plugin
        -->
        select
        <include refid="Base_Column_List"/>
        from dc_mid_cost_first
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
        limit 1
    </select>
</mapper>
