<?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.SupplierContractItemMapper">
  
<resultMap id="BaseResultMap" type="com.boco.nbd.wios.manage.entity.bo.SupplierContractItem">
  <id column="id" jdbcType="INTEGER" property="id" />
  <result column="contract_id" jdbcType="INTEGER" property="contractId" />
  <result column="item_id" jdbcType="VARCHAR" property="itemId" />
  <result column="type" jdbcType="VARCHAR" property="type" />
  <result column="price" jdbcType="DECIMAL" property="price" />
  <result column="tax_rate" jdbcType="DECIMAL" property="taxRate" />
  <result column="rate_price" jdbcType="DECIMAL" property="ratePrice" />
  <result column="description" jdbcType="VARCHAR" property="description" />
  <result column="create_account" jdbcType="VARCHAR" property="createAccount" />
  <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  <result column="modify_account" jdbcType="VARCHAR" property="modifyAccount" />
  <result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime" />
</resultMap>

  
<sql id="Base_Column_List">
  id, contract_id, item_id, type, price, tax_rate, rate_price, description, create_account, 
  create_time, modify_account, modify_time
</sql>

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

  
<insert id="insert" parameterType="com.boco.nbd.wios.manage.entity.bo.SupplierContractItem">
  insert into t_supplier_contract_item (id, contract_id, item_id, 
    type, price, tax_rate, 
    rate_price, description, create_account, 
    create_time, modify_account, modify_time
    )
  values (#{id,jdbcType=INTEGER}, #{contractId,jdbcType=INTEGER}, #{itemId,jdbcType=VARCHAR}, 
    #{type,jdbcType=VARCHAR}, #{price,jdbcType=DECIMAL}, #{taxRate,jdbcType=DECIMAL}, 
    #{ratePrice,jdbcType=DECIMAL}, #{description,jdbcType=VARCHAR}, #{createAccount,jdbcType=VARCHAR}, 
    #{createTime,jdbcType=TIMESTAMP}, #{modifyAccount,jdbcType=VARCHAR}, #{modifyTime,jdbcType=TIMESTAMP}
    )
</insert>

  
<insert id="insertDynamic" parameterType="com.boco.nbd.wios.manage.entity.bo.SupplierContractItem">
  insert into t_supplier_contract_item
  <trim prefix="(" suffix=")" suffixOverrides=",">
    <if test="id != null">
      id,
    </if>
    <if test="contractId != null">
      contract_id,
    </if>
    <if test="itemId != null">
      item_id,
    </if>
    <if test="type != null">
      type,
    </if>
    <if test="price != null">
      price,
    </if>
    <if test="taxRate != null">
      tax_rate,
    </if>
    <if test="ratePrice != null">
      rate_price,
    </if>
    <if test="description != null">
      description,
    </if>
    <if test="createAccount != null">
      create_account,
    </if>
    <if test="createTime != null">
      create_time,
    </if>
    <if test="modifyAccount != null">
      modify_account,
    </if>
    <if test="modifyTime != null">
      modify_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="itemId != null">
      #{itemId,jdbcType=VARCHAR},
    </if>
    <if test="type != null">
      #{type,jdbcType=VARCHAR},
    </if>
    <if test="price != null">
      #{price,jdbcType=DECIMAL},
    </if>
    <if test="taxRate != null">
      #{taxRate,jdbcType=DECIMAL},
    </if>
    <if test="ratePrice != null">
      #{ratePrice,jdbcType=DECIMAL},
    </if>
    <if test="description != null">
      #{description,jdbcType=VARCHAR},
    </if>
    <if test="createAccount != null">
      #{createAccount,jdbcType=VARCHAR},
    </if>
    <if test="createTime != null">
      #{createTime,jdbcType=TIMESTAMP},
    </if>
    <if test="modifyAccount != null">
      #{modifyAccount,jdbcType=VARCHAR},
    </if>
    <if test="modifyTime != null">
      #{modifyTime,jdbcType=TIMESTAMP},
    </if>
  </trim>
</insert>

  
<update id="updateDynamic" parameterType="com.boco.nbd.wios.manage.entity.bo.SupplierContractItem">
  update t_supplier_contract_item
  <set>
    <if test="contractId != null">
      contract_id = #{contractId,jdbcType=INTEGER},
    </if>
    <if test="itemId != null">
      item_id = #{itemId,jdbcType=VARCHAR},
    </if>
    <if test="type != null">
      type = #{type,jdbcType=VARCHAR},
    </if>
    <if test="price != null">
      price = #{price,jdbcType=DECIMAL},
    </if>
    <if test="taxRate != null">
      tax_rate = #{taxRate,jdbcType=DECIMAL},
    </if>
    <if test="ratePrice != null">
      rate_price = #{ratePrice,jdbcType=DECIMAL},
    </if>
    <if test="description != null">
      description = #{description,jdbcType=VARCHAR},
    </if>
    <if test="createAccount != null">
      create_account = #{createAccount,jdbcType=VARCHAR},
    </if>
    <if test="createTime != null">
      create_time = #{createTime,jdbcType=TIMESTAMP},
    </if>
    <if test="modifyAccount != null">
      modify_account = #{modifyAccount,jdbcType=VARCHAR},
    </if>
    <if test="modifyTime != null">
      modify_time = #{modifyTime,jdbcType=TIMESTAMP},
    </if>
  </set>
  where id = #{id,jdbcType=INTEGER}
</update>

  
<update id="update" parameterType="com.boco.nbd.wios.manage.entity.bo.SupplierContractItem">
  update t_supplier_contract_item
  set contract_id = #{contractId,jdbcType=INTEGER},
    item_id = #{itemId,jdbcType=VARCHAR},
    type = #{type,jdbcType=VARCHAR},
    price = #{price,jdbcType=DECIMAL},
    tax_rate = #{taxRate,jdbcType=DECIMAL},
    rate_price = #{ratePrice,jdbcType=DECIMAL},
    description = #{description,jdbcType=VARCHAR},
    create_account = #{createAccount,jdbcType=VARCHAR},
    create_time = #{createTime,jdbcType=TIMESTAMP},
    modify_account = #{modifyAccount,jdbcType=VARCHAR},
    modify_time = #{modifyTime,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_item
  where id = #{id,jdbcType=INTEGER}
</select>

<select id="selectByContractId" parameterType="java.lang.Integer" resultType="com.boco.nbd.wios.manage.entity.bo.SupplierContractItemVo">
  select t.*
  from  t_supplier_contract_item t
  where t.contract_id = #{contractId,jdbcType=INTEGER}
</select>

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

<select id="selectByItemId" parameterType="java.lang.String" resultMap="BaseResultMap">
  select t.*
  from  t_supplier_contract_item t
  where t.item_id = #{itemId}
</select>

<insert id="batchInsert" parameterType="java.util.List">
    insert into t_supplier_contract_item (id, contract_id, item_id, 
    type, price, tax_rate, 
    rate_price, description, create_account, 
    create_time, modify_account, modify_time
    )
  values 
  <foreach collection="list" item="item" separator=",">
  (#{item.id,jdbcType=INTEGER}, #{item.contractId,jdbcType=INTEGER}, #{item.itemId,jdbcType=VARCHAR}, 
    #{item.type,jdbcType=VARCHAR}, #{item.price,jdbcType=DECIMAL}, #{item.taxRate,jdbcType=DECIMAL}, 
    #{item.ratePrice,jdbcType=DECIMAL}, #{item.description,jdbcType=VARCHAR}, #{item.createAccount,jdbcType=VARCHAR}, 
    #{item.createTime,jdbcType=TIMESTAMP}, #{item.modifyAccount,jdbcType=VARCHAR}, #{item.modifyTime,jdbcType=TIMESTAMP}
    )
  </foreach>
</insert>

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

</mapper>