<?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.TbOrderItemMapper" >
  <resultMap id="BaseResultMap" type="com.xmomen.module.order.entity.TbOrderItem" >
    <id column="ID" property="id" jdbcType="INTEGER" />
    <result column="ORDER_NO" property="orderNo" jdbcType="VARCHAR" />
    <result column="ITEM_ID" property="itemId" jdbcType="INTEGER" />
    <result column="ITEM_CODE" property="itemCode" jdbcType="VARCHAR" />
    <result column="ITEM_NAME" property="itemName" jdbcType="VARCHAR" />
    <result column="ITEM_PRICE" property="itemPrice" jdbcType="DECIMAL" />
    <result column="ITEM_QTY" property="itemQty" jdbcType="DECIMAL" />
    <result column="ITEM_UNIT" property="itemUnit" jdbcType="VARCHAR" />
    <result column="CREATE_DATE" property="createDate" jdbcType="TIMESTAMP" />
    <result column="CREATE_USER_ID" property="createUserId" jdbcType="INTEGER" />
    <result column="UPDATE_DATE" property="updateDate" jdbcType="TIMESTAMP" />
    <result column="UPDATE_USER_ID" property="updateUserId" jdbcType="INTEGER" />
  </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, ORDER_NO, ITEM_ID, ITEM_CODE, ITEM_NAME, ITEM_PRICE, ITEM_QTY, ITEM_UNIT, CREATE_DATE, 
    CREATE_USER_ID, UPDATE_DATE, UPDATE_USER_ID
  </sql>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.xmomen.module.order.entity.TbOrderItemExample" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    from tb_order_item
    <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.TbOrderItemExample" >
    delete from tb_order_item
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insertSelective" parameterType="com.xmomen.module.order.entity.TbOrderItem" useGeneratedKeys="true" keyProperty="id" keyColumn="ID" >
    insert into tb_order_item
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        ID,
      </if>
      <if test="orderNo != null" >
        ORDER_NO,
      </if>
      <if test="itemId != null" >
        ITEM_ID,
      </if>
      <if test="itemCode != null" >
        ITEM_CODE,
      </if>
      <if test="itemName != null" >
        ITEM_NAME,
      </if>
      <if test="itemPrice != null" >
        ITEM_PRICE,
      </if>
      <if test="itemQty != null" >
        ITEM_QTY,
      </if>
      <if test="itemUnit != null" >
        ITEM_UNIT,
      </if>
      <if test="createDate != null" >
        CREATE_DATE,
      </if>
      <if test="createUserId != null" >
        CREATE_USER_ID,
      </if>
      <if test="updateDate != null" >
        UPDATE_DATE,
      </if>
      <if test="updateUserId != null" >
        UPDATE_USER_ID,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="orderNo != null" >
        #{orderNo,jdbcType=VARCHAR},
      </if>
      <if test="itemId != null" >
        #{itemId,jdbcType=INTEGER},
      </if>
      <if test="itemCode != null" >
        #{itemCode,jdbcType=VARCHAR},
      </if>
      <if test="itemName != null" >
        #{itemName,jdbcType=VARCHAR},
      </if>
      <if test="itemPrice != null" >
        #{itemPrice,jdbcType=DECIMAL},
      </if>
      <if test="itemQty != null" >
        #{itemQty,jdbcType=DECIMAL},
      </if>
      <if test="itemUnit != null" >
        #{itemUnit,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null" >
        #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="createUserId != null" >
        #{createUserId,jdbcType=INTEGER},
      </if>
      <if test="updateDate != null" >
        #{updateDate,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUserId != null" >
        #{updateUserId,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.xmomen.module.order.entity.TbOrderItemExample" resultType="java.lang.Integer" >
    select count(*) from tb_order_item
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map" >
    update tb_order_item
    <set >
      <if test="record.id != null" >
        ID = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.orderNo != null" >
        ORDER_NO = #{record.orderNo,jdbcType=VARCHAR},
      </if>
      <if test="record.itemId != null" >
        ITEM_ID = #{record.itemId,jdbcType=INTEGER},
      </if>
      <if test="record.itemCode != null" >
        ITEM_CODE = #{record.itemCode,jdbcType=VARCHAR},
      </if>
      <if test="record.itemName != null" >
        ITEM_NAME = #{record.itemName,jdbcType=VARCHAR},
      </if>
      <if test="record.itemPrice != null" >
        ITEM_PRICE = #{record.itemPrice,jdbcType=DECIMAL},
      </if>
      <if test="record.itemQty != null" >
        ITEM_QTY = #{record.itemQty,jdbcType=DECIMAL},
      </if>
      <if test="record.itemUnit != null" >
        ITEM_UNIT = #{record.itemUnit,jdbcType=VARCHAR},
      </if>
      <if test="record.createDate != null" >
        CREATE_DATE = #{record.createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createUserId != null" >
        CREATE_USER_ID = #{record.createUserId,jdbcType=INTEGER},
      </if>
      <if test="record.updateDate != null" >
        UPDATE_DATE = #{record.updateDate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.updateUserId != null" >
        UPDATE_USER_ID = #{record.updateUserId,jdbcType=INTEGER},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
</mapper>