<?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.xmomen.module.order.entity.mapper.TbPurchaseMapper" >
  <resultMap id="BaseResultMap" type="com.xmomen.module.order.entity.TbPurchase" >
    <id column="ID" property="id" jdbcType="INTEGER" />
    <result column="PURCHASE_CODE" property="purchaseCode" jdbcType="VARCHAR" />
    <result column="ITEM_CODE" property="itemCode" jdbcType="VARCHAR" />
    <result column="TOTAL" property="total" jdbcType="DECIMAL" />
    <result column="CREATE_DATE" property="createDate" jdbcType="TIMESTAMP" />
    <result column="BUYER_ID" property="buyerId" jdbcType="INTEGER" />
    <result column="TOTAL_WEIGHT" property="totalWeight" jdbcType="DECIMAL" />
    <result column="DISTRIBUTE_VALUE" property="distributeValue" jdbcType="INTEGER" />
    <result column="PACKAGE_VALUE" property="packageValue" jdbcType="INTEGER" />
    <result column="PACKING_VALUE" property="packingValue" jdbcType="INTEGER" />
    <result column="PURCHASE_STATUS" property="purchaseStatus" jdbcType="BIT" />
  </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" >
    ID, PURCHASE_CODE, ITEM_CODE, TOTAL, CREATE_DATE, BUYER_ID, TOTAL_WEIGHT, DISTRIBUTE_VALUE, 
    PACKAGE_VALUE, PACKING_VALUE, PURCHASE_STATUS
  </sql>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.xmomen.module.order.entity.TbPurchaseExample" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    from tb_purchase
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null" >
      order by ${orderByClause}
    </if>
  </select>
  <delete id="deleteByExample" parameterType="com.xmomen.module.order.entity.TbPurchaseExample" >
    delete from tb_purchase
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insertSelective" parameterType="com.xmomen.module.order.entity.TbPurchase" useGeneratedKeys="true" keyProperty="id" keyColumn="ID" >
    insert into tb_purchase
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        ID,
      </if>
      <if test="purchaseCode != null" >
        PURCHASE_CODE,
      </if>
      <if test="itemCode != null" >
        ITEM_CODE,
      </if>
      <if test="total != null" >
        TOTAL,
      </if>
      <if test="createDate != null" >
        CREATE_DATE,
      </if>
      <if test="buyerId != null" >
        BUYER_ID,
      </if>
      <if test="totalWeight != null" >
        TOTAL_WEIGHT,
      </if>
      <if test="distributeValue != null" >
        DISTRIBUTE_VALUE,
      </if>
      <if test="packageValue != null" >
        PACKAGE_VALUE,
      </if>
      <if test="packingValue != null" >
        PACKING_VALUE,
      </if>
      <if test="purchaseStatus != null" >
        PURCHASE_STATUS,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="purchaseCode != null" >
        #{purchaseCode,jdbcType=VARCHAR},
      </if>
      <if test="itemCode != null" >
        #{itemCode,jdbcType=VARCHAR},
      </if>
      <if test="total != null" >
        #{total,jdbcType=DECIMAL},
      </if>
      <if test="createDate != null" >
        #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="buyerId != null" >
        #{buyerId,jdbcType=INTEGER},
      </if>
      <if test="totalWeight != null" >
        #{totalWeight,jdbcType=DECIMAL},
      </if>
      <if test="distributeValue != null" >
        #{distributeValue,jdbcType=INTEGER},
      </if>
      <if test="packageValue != null" >
        #{packageValue,jdbcType=INTEGER},
      </if>
      <if test="packingValue != null" >
        #{packingValue,jdbcType=INTEGER},
      </if>
      <if test="purchaseStatus != null" >
        #{purchaseStatus,jdbcType=BIT},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.xmomen.module.order.entity.TbPurchaseExample" resultType="java.lang.Integer" >
    select count(*) from tb_purchase
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map" >
    update tb_purchase
    <set >
      <if test="record.id != null" >
        ID = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.purchaseCode != null" >
        PURCHASE_CODE = #{record.purchaseCode,jdbcType=VARCHAR},
      </if>
      <if test="record.itemCode != null" >
        ITEM_CODE = #{record.itemCode,jdbcType=VARCHAR},
      </if>
      <if test="record.total != null" >
        TOTAL = #{record.total,jdbcType=DECIMAL},
      </if>
      <if test="record.createDate != null" >
        CREATE_DATE = #{record.createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.buyerId != null" >
        BUYER_ID = #{record.buyerId,jdbcType=INTEGER},
      </if>
      <if test="record.totalWeight != null" >
        TOTAL_WEIGHT = #{record.totalWeight,jdbcType=DECIMAL},
      </if>
      <if test="record.distributeValue != null" >
        DISTRIBUTE_VALUE = #{record.distributeValue,jdbcType=INTEGER},
      </if>
      <if test="record.packageValue != null" >
        PACKAGE_VALUE = #{record.packageValue,jdbcType=INTEGER},
      </if>
      <if test="record.packingValue != null" >
        PACKING_VALUE = #{record.packingValue,jdbcType=INTEGER},
      </if>
      <if test="record.purchaseStatus != null" >
        PURCHASE_STATUS = #{record.purchaseStatus,jdbcType=BIT},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
</mapper>