<?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.base.entity.mapper.CdContractItemMapper" >
  <resultMap id="BaseResultMap" type="com.xmomen.module.base.entity.CdContractItem" >
    <id column="ID" property="id" jdbcType="INTEGER" />
    <result column="CD_CONTRACT_ID" property="cdContractId" jdbcType="INTEGER" />
    <result column="CONTRACT_TYPE" property="contractType" jdbcType="INTEGER" />
    <result column="CD_ITEM_ID" property="cdItemId" jdbcType="INTEGER" />
    <result column="DISCOUNT" property="discount" jdbcType="DOUBLE" />
    <result column="CONTRACT_VALUE" property="contractValue" 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" >
    ID, CD_CONTRACT_ID, CONTRACT_TYPE, CD_ITEM_ID, DISCOUNT, CONTRACT_VALUE
  </sql>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.xmomen.module.base.entity.CdContractItemExample" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    from cd_contract_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.base.entity.CdContractItemExample" >
    delete from cd_contract_item
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insertSelective" parameterType="com.xmomen.module.base.entity.CdContractItem" useGeneratedKeys="true" keyProperty="id" keyColumn="ID" >
    insert into cd_contract_item
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        ID,
      </if>
      <if test="cdContractId != null" >
        CD_CONTRACT_ID,
      </if>
      <if test="contractType != null" >
        CONTRACT_TYPE,
      </if>
      <if test="cdItemId != null" >
        CD_ITEM_ID,
      </if>
      <if test="discount != null" >
        DISCOUNT,
      </if>
      <if test="contractValue != null" >
        CONTRACT_VALUE,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="cdContractId != null" >
        #{cdContractId,jdbcType=INTEGER},
      </if>
      <if test="contractType != null" >
        #{contractType,jdbcType=INTEGER},
      </if>
      <if test="cdItemId != null" >
        #{cdItemId,jdbcType=INTEGER},
      </if>
      <if test="discount != null" >
        #{discount,jdbcType=DOUBLE},
      </if>
      <if test="contractValue != null" >
        #{contractValue,jdbcType=DECIMAL},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.xmomen.module.base.entity.CdContractItemExample" resultType="java.lang.Integer" >
    select count(*) from cd_contract_item
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map" >
    update cd_contract_item
    <set >
      <if test="record.id != null" >
        ID = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.cdContractId != null" >
        CD_CONTRACT_ID = #{record.cdContractId,jdbcType=INTEGER},
      </if>
      <if test="record.contractType != null" >
        CONTRACT_TYPE = #{record.contractType,jdbcType=INTEGER},
      </if>
      <if test="record.cdItemId != null" >
        CD_ITEM_ID = #{record.cdItemId,jdbcType=INTEGER},
      </if>
      <if test="record.discount != null" >
        DISCOUNT = #{record.discount,jdbcType=DOUBLE},
      </if>
      <if test="record.contractValue != null" >
        CONTRACT_VALUE = #{record.contractValue,jdbcType=DECIMAL},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
</mapper>