<?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.extdb.WarehouseMaterialsMapper" >
  <resultMap id="BaseResultMap" type="com.boco.nbd.wios.manage.entity.bo.WarehouseMaterials" >
    <id column="materials_id" property="materialsId" jdbcType="VARCHAR" />
    <id column="warehouse_id" property="warehouseId" jdbcType="VARCHAR" />
    <result column="total_number" property="totalNumber" jdbcType="DECIMAL" />
    <result column="has_number" property="hasNumber" jdbcType="DECIMAL" />
    <result column="remaining_number" property="remainingNumber" jdbcType="DECIMAL" />
    <result column="stay_with_number" property="stayWithNumber" jdbcType="DECIMAL" />
  </resultMap>
  <sql id="Example_Where_Clause" >
    <where >
      <foreach collection="oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <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 collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause" >
    <where >
      <foreach collection="example.oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <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 collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List" >
    materials_id, warehouse_id, total_number, has_number, remaining_number, stay_with_number
  </sql>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.boco.nbd.wios.manage.entity.bo.WarehouseMaterialsCriteria" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    from t_warehouse_materials
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null" >
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="com.boco.nbd.wios.manage.entity.bo.WarehouseMaterialsKey" >
    select 
    <include refid="Base_Column_List" />
    from t_warehouse_materials
    where materials_id = #{materialsId,jdbcType=VARCHAR}
      and warehouse_id = #{warehouseId,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="com.boco.nbd.wios.manage.entity.bo.WarehouseMaterialsKey" >
    delete from t_warehouse_materials
    where materials_id = #{materialsId,jdbcType=VARCHAR}
      and warehouse_id = #{warehouseId,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="com.boco.nbd.wios.manage.entity.bo.WarehouseMaterialsCriteria" >
    delete from t_warehouse_materials
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.boco.nbd.wios.manage.entity.bo.WarehouseMaterials" >
    insert into t_warehouse_materials (materials_id, warehouse_id, total_number, 
      has_number, remaining_number, stay_with_number
      )
    values (#{materialsId,jdbcType=VARCHAR}, #{warehouseId,jdbcType=VARCHAR}, #{totalNumber,jdbcType=DECIMAL}, 
      #{hasNumber,jdbcType=DECIMAL}, #{remainingNumber,jdbcType=DECIMAL}, #{stayWithNumber,jdbcType=DECIMAL}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.boco.nbd.wios.manage.entity.bo.WarehouseMaterials" >
    insert into t_warehouse_materials
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="materialsId != null" >
        materials_id,
      </if>
      <if test="warehouseId != null" >
        warehouse_id,
      </if>
      <if test="totalNumber != null" >
        total_number,
      </if>
      <if test="hasNumber != null" >
        has_number,
      </if>
      <if test="remainingNumber != null" >
        remaining_number,
      </if>
      <if test="stayWithNumber != null" >
        stay_with_number,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="materialsId != null" >
        #{materialsId,jdbcType=VARCHAR},
      </if>
      <if test="warehouseId != null" >
        #{warehouseId,jdbcType=VARCHAR},
      </if>
      <if test="totalNumber != null" >
        #{totalNumber,jdbcType=DECIMAL},
      </if>
      <if test="hasNumber != null" >
        #{hasNumber,jdbcType=DECIMAL},
      </if>
      <if test="remainingNumber != null" >
        #{remainingNumber,jdbcType=DECIMAL},
      </if>
      <if test="stayWithNumber != null" >
        #{stayWithNumber,jdbcType=DECIMAL},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.boco.nbd.wios.manage.entity.bo.WarehouseMaterialsCriteria" resultType="java.lang.Integer" >
    select count(*) from t_warehouse_materials
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map" >
    update t_warehouse_materials
    <set >
      <if test="record.materialsId != null" >
        materials_id = #{record.materialsId,jdbcType=VARCHAR},
      </if>
      <if test="record.warehouseId != null" >
        warehouse_id = #{record.warehouseId,jdbcType=VARCHAR},
      </if>
      <if test="record.totalNumber != null" >
        total_number = #{record.totalNumber,jdbcType=DECIMAL},
      </if>
      <if test="record.hasNumber != null" >
        has_number = #{record.hasNumber,jdbcType=DECIMAL},
      </if>
      <if test="record.remainingNumber != null" >
        remaining_number = #{record.remainingNumber,jdbcType=DECIMAL},
      </if>
      <if test="record.stayWithNumber != null" >
        stay_with_number = #{record.stayWithNumber,jdbcType=DECIMAL},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map" >
    update t_warehouse_materials
    set materials_id = #{record.materialsId,jdbcType=VARCHAR},
      warehouse_id = #{record.warehouseId,jdbcType=VARCHAR},
      total_number = #{record.totalNumber,jdbcType=DECIMAL},
      has_number = #{record.hasNumber,jdbcType=DECIMAL},
      remaining_number = #{record.remainingNumber,jdbcType=DECIMAL},
      stay_with_number = #{record.stayWithNumber,jdbcType=DECIMAL}
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.boco.nbd.wios.manage.entity.bo.WarehouseMaterials" >
    update t_warehouse_materials
    <set >
      <if test="totalNumber != null" >
        total_number = #{totalNumber,jdbcType=DECIMAL},
      </if>
      <if test="hasNumber != null" >
        has_number = #{hasNumber,jdbcType=DECIMAL},
      </if>
      <if test="remainingNumber != null" >
        remaining_number = #{remainingNumber,jdbcType=DECIMAL},
      </if>
      <if test="stayWithNumber != null" >
        stay_with_number = #{stayWithNumber,jdbcType=DECIMAL},
      </if>
    </set>
    where materials_id = #{materialsId,jdbcType=VARCHAR}
      and warehouse_id = #{warehouseId,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.boco.nbd.wios.manage.entity.bo.WarehouseMaterials" >
    update t_warehouse_materials
    set total_number = #{totalNumber,jdbcType=DECIMAL},
      has_number = #{hasNumber,jdbcType=DECIMAL},
      remaining_number = #{remainingNumber,jdbcType=DECIMAL},
      stay_with_number = #{stayWithNumber,jdbcType=DECIMAL}
    where materials_id = #{materialsId,jdbcType=VARCHAR}
      and warehouse_id = #{warehouseId,jdbcType=VARCHAR}
  </update>
</mapper>