<?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.boco.nbd.wios.manage.mapper.def.SupplierContractPackPriceMapper">
  
<resultMap id="BaseResultMap" type="com.boco.nbd.wios.manage.entity.bo.SupplierContractPackPrice">
  <id column="id" jdbcType="INTEGER" property="id" />
  <result column="contract_id" jdbcType="INTEGER" property="contractId" />
  <result column="region_id" jdbcType="INTEGER" property="regionId" />
  <result column="oem_id" jdbcType="INTEGER" property="oemId" />
  <result column="device_model" jdbcType="VARCHAR" property="deviceModel" />
  <result column="cable_length" jdbcType="DOUBLE" property="cableLength" />
  <result column="price" jdbcType="DECIMAL" property="price" />
  <result column="price_with_tax" jdbcType="DECIMAL" property="priceWithTax" />
  <result column="cable_length_two" jdbcType="DOUBLE" property="cableLengthTwo" />
  <result column="price_two" jdbcType="DECIMAL" property="priceTwo" />
  <result column="price_with_tax_two" jdbcType="DECIMAL" property="priceWithTaxTwo" />
  <result column="remark" jdbcType="VARCHAR" property="remark" />
  <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>

  
<sql id="Base_Column_List">
  id, contract_id, region_id, oem_id, device_model, cable_length, price, price_with_tax, 
  cable_length_two, price_two, price_with_tax_two, remark, create_time, update_time
</sql>

  
<delete id="delete" parameterType="java.lang.Integer">
  delete from t_supplier_contract_pack_price
  where id = #{id,jdbcType=INTEGER}
</delete>

  
<insert id="insert" parameterType="com.boco.nbd.wios.manage.entity.bo.SupplierContractPackPrice">
  insert into t_supplier_contract_pack_price (id, contract_id, region_id, 
    oem_id, device_model, cable_length, 
    price, price_with_tax, cable_length_two, 
    price_two, price_with_tax_two, remark, 
    create_time, update_time)
  values (#{id,jdbcType=INTEGER}, #{contractId,jdbcType=INTEGER}, #{regionId,jdbcType=INTEGER}, 
    #{oemId,jdbcType=INTEGER}, #{deviceModel,jdbcType=VARCHAR}, #{cableLength,jdbcType=DOUBLE}, 
    #{price,jdbcType=DECIMAL}, #{priceWithTax,jdbcType=DECIMAL}, #{cableLengthTwo,jdbcType=DOUBLE}, 
    #{priceTwo,jdbcType=DECIMAL}, #{priceWithTaxTwo,jdbcType=DECIMAL}, #{remark,jdbcType=VARCHAR}, 
    #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
</insert>

  
<insert id="insertDynamic" parameterType="com.boco.nbd.wios.manage.entity.bo.SupplierContractPackPrice">
  insert into t_supplier_contract_pack_price
  <trim prefix="(" suffix=")" suffixOverrides=",">
    <if test="id != null">
      id,
    </if>
    <if test="contractId != null">
      contract_id,
    </if>
    <if test="regionId != null">
      region_id,
    </if>
    <if test="oemId != null">
      oem_id,
    </if>
    <if test="deviceModel != null">
      device_model,
    </if>
    <if test="cableLength != null">
      cable_length,
    </if>
    <if test="price != null">
      price,
    </if>
    <if test="priceWithTax != null">
      price_with_tax,
    </if>
    <if test="cableLengthTwo != null">
      cable_length_two,
    </if>
    <if test="priceTwo != null">
      price_two,
    </if>
    <if test="priceWithTaxTwo != null">
      price_with_tax_two,
    </if>
    <if test="remark != null">
      remark,
    </if>
    <if test="createTime != null">
      create_time,
    </if>
    <if test="updateTime != null">
      update_time,
    </if>
  </trim>
  <trim prefix="values (" suffix=")" suffixOverrides=",">
    <if test="id != null">
      #{id,jdbcType=INTEGER},
    </if>
    <if test="contractId != null">
      #{contractId,jdbcType=INTEGER},
    </if>
    <if test="regionId != null">
      #{regionId,jdbcType=INTEGER},
    </if>
    <if test="oemId != null">
      #{oemId,jdbcType=INTEGER},
    </if>
    <if test="deviceModel != null">
      #{deviceModel,jdbcType=VARCHAR},
    </if>
    <if test="cableLength != null">
      #{cableLength,jdbcType=DOUBLE},
    </if>
    <if test="price != null">
      #{price,jdbcType=DECIMAL},
    </if>
    <if test="priceWithTax != null">
      #{priceWithTax,jdbcType=DECIMAL},
    </if>
    <if test="cableLengthTwo != null">
      #{cableLengthTwo,jdbcType=DOUBLE},
    </if>
    <if test="priceTwo != null">
      #{priceTwo,jdbcType=DECIMAL},
    </if>
    <if test="priceWithTaxTwo != null">
      #{priceWithTaxTwo,jdbcType=DECIMAL},
    </if>
    <if test="remark != null">
      #{remark,jdbcType=VARCHAR},
    </if>
    <if test="createTime != null">
      #{createTime,jdbcType=TIMESTAMP},
    </if>
    <if test="updateTime != null">
      #{updateTime,jdbcType=TIMESTAMP},
    </if>
  </trim>
</insert>

  
<update id="updateDynamic" parameterType="com.boco.nbd.wios.manage.entity.bo.SupplierContractPackPrice">
  update t_supplier_contract_pack_price
  <set>
    <if test="contractId != null">
      contract_id = #{contractId,jdbcType=INTEGER},
    </if>
    <if test="regionId != null">
      region_id = #{regionId,jdbcType=INTEGER},
    </if>
    <if test="oemId != null">
      oem_id = #{oemId,jdbcType=INTEGER},
    </if>
    <if test="deviceModel != null">
      device_model = #{deviceModel,jdbcType=VARCHAR},
    </if>
    <if test="cableLength != null">
      cable_length = #{cableLength,jdbcType=DOUBLE},
    </if>
    <if test="price != null">
      price = #{price,jdbcType=DECIMAL},
    </if>
    <if test="priceWithTax != null">
      price_with_tax = #{priceWithTax,jdbcType=DECIMAL},
    </if>
    <if test="cableLengthTwo != null">
      cable_length_two = #{cableLengthTwo,jdbcType=DOUBLE},
    </if>
    <if test="priceTwo != null">
      price_two = #{priceTwo,jdbcType=DECIMAL},
    </if>
    <if test="priceWithTaxTwo != null">
      price_with_tax_two = #{priceWithTaxTwo,jdbcType=DECIMAL},
    </if>
    <if test="remark != null">
      remark = #{remark,jdbcType=VARCHAR},
    </if>
    <if test="createTime != null">
      create_time = #{createTime,jdbcType=TIMESTAMP},
    </if>
    <if test="updateTime != null">
      update_time = #{updateTime,jdbcType=TIMESTAMP},
    </if>
  </set>
  where id = #{id,jdbcType=INTEGER}
</update>

  
<update id="update" parameterType="com.boco.nbd.wios.manage.entity.bo.SupplierContractPackPrice">
  update t_supplier_contract_pack_price
  set contract_id = #{contractId,jdbcType=INTEGER},
    region_id = #{regionId,jdbcType=INTEGER},
    oem_id = #{oemId,jdbcType=INTEGER},
    device_model = #{deviceModel,jdbcType=VARCHAR},
    cable_length = #{cableLength,jdbcType=DOUBLE},
    price = #{price,jdbcType=DECIMAL},
    price_with_tax = #{priceWithTax,jdbcType=DECIMAL},
    cable_length_two = #{cableLengthTwo,jdbcType=DOUBLE},
    price_two = #{priceTwo,jdbcType=DECIMAL},
    price_with_tax_two = #{priceWithTaxTwo,jdbcType=DECIMAL},
    remark = #{remark,jdbcType=VARCHAR},
    create_time = #{createTime,jdbcType=TIMESTAMP},
    update_time = #{updateTime,jdbcType=TIMESTAMP}
  where id = #{id,jdbcType=INTEGER}
</update>

  
<select id="selectById" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  select
	<include refid="Base_Column_List" />
  from  t_supplier_contract_pack_price
  where id = #{id,jdbcType=INTEGER}
</select>

<select id="selectByContractId" parameterType="java.lang.Integer" resultType="com.boco.nbd.wios.manage.entity.bo.SupplierContractPackPriceVo">
  select t.*,o.name as oemName,r.name as regionName,r.id_tree as regionIdTree
  from  t_supplier_contract_pack_price t
  left join t_oem o on o.id=t.oem_id
  left join t_region r on r.id=t.region_id
  where t.contract_id = #{contractId,jdbcType=INTEGER}
</select>

<select id="selectPureByContractId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  select t.*
  from  t_supplier_contract_pack_price t
  where t.contract_id = #{contractId,jdbcType=INTEGER}
</select>

<insert id="batchInsert"  parameterType="java.util.List">
  insert into t_supplier_contract_pack_price (id, contract_id, region_id,
    oem_id, device_model, cable_length, 
    price, price_with_tax, cable_length_two, 
    price_two, price_with_tax_two, remark, 
    create_time, update_time)
  values 
  <foreach collection="list" item="item" separator=",">
  (#{item.id,jdbcType=INTEGER}, #{item.contractId,jdbcType=INTEGER}, #{item.regionId,jdbcType=INTEGER},
    #{item.oemId,jdbcType=INTEGER}, #{item.deviceModel,jdbcType=VARCHAR}, #{item.cableLength,jdbcType=DOUBLE}, 
    #{item.price,jdbcType=DECIMAL}, #{item.priceWithTax,jdbcType=DECIMAL}, #{item.cableLengthTwo,jdbcType=DOUBLE}, 
    #{item.priceTwo,jdbcType=DECIMAL}, #{item.priceWithTaxTwo,jdbcType=DECIMAL}, #{item.remark,jdbcType=VARCHAR}, 
    #{item.createTime,jdbcType=TIMESTAMP}, #{item.updateTime,jdbcType=TIMESTAMP})
   </foreach>
</insert>

<delete id="deleteByContractId" parameterType="java.lang.Integer">
  delete from t_supplier_contract_pack_price
  where contract_id = #{contractId}
</delete>

</mapper>