<?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.CdPlanMapper" >
  <resultMap id="BaseResultMap" type="com.xmomen.module.base.entity.CdPlan" >
    <id column="ID" property="id" jdbcType="INTEGER" />
    <result column="PLAN_NAME" property="planName" jdbcType="VARCHAR" />
    <result column="CREATE_USER" property="createUser" jdbcType="VARCHAR" />
    <result column="CREATE_TIME" property="createTime" jdbcType="TIMESTAMP" />
    <result column="DELIVERY_TYPE" property="deliveryType" jdbcType="INTEGER" />
    <result column="DELIVERY_TIME" property="deliveryTime" jdbcType="VARCHAR" />
    <result column="DELIVER_COUNT" property="deliverCount" jdbcType="INTEGER" />
    <result column="PRICE" property="price" jdbcType="DOUBLE" />
    <result column="IS_RANDOM" property="isRandom" jdbcType="INTEGER" />
    <result column="CD_CATEGORY_ID" property="cdCategoryId" jdbcType="INTEGER" />
    <result column="RANDOM_NUM" property="randomNum" jdbcType="INTEGER" />
    <result column="BEGIN_TIME" property="beginTime" jdbcType="TIMESTAMP" />
  </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, PLAN_NAME, CREATE_USER, CREATE_TIME, DELIVERY_TYPE, DELIVERY_TIME, DELIVER_COUNT, 
    PRICE, IS_RANDOM, CD_CATEGORY_ID, RANDOM_NUM, BEGIN_TIME
  </sql>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.xmomen.module.base.entity.CdPlanExample" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    from cd_plan
    <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.CdPlanExample" >
    delete from cd_plan
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insertSelective" parameterType="com.xmomen.module.base.entity.CdPlan" useGeneratedKeys="true" keyProperty="id" keyColumn="ID" >
    insert into cd_plan
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        ID,
      </if>
      <if test="planName != null" >
        PLAN_NAME,
      </if>
      <if test="createUser != null" >
        CREATE_USER,
      </if>
      <if test="createTime != null" >
        CREATE_TIME,
      </if>
      <if test="deliveryType != null" >
        DELIVERY_TYPE,
      </if>
      <if test="deliveryTime != null" >
        DELIVERY_TIME,
      </if>
      <if test="deliverCount != null" >
        DELIVER_COUNT,
      </if>
      <if test="price != null" >
        PRICE,
      </if>
      <if test="isRandom != null" >
        IS_RANDOM,
      </if>
      <if test="cdCategoryId != null" >
        CD_CATEGORY_ID,
      </if>
      <if test="randomNum != null" >
        RANDOM_NUM,
      </if>
      <if test="beginTime != null" >
        BEGIN_TIME,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="planName != null" >
        #{planName,jdbcType=VARCHAR},
      </if>
      <if test="createUser != null" >
        #{createUser,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null" >
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="deliveryType != null" >
        #{deliveryType,jdbcType=INTEGER},
      </if>
      <if test="deliveryTime != null" >
        #{deliveryTime,jdbcType=VARCHAR},
      </if>
      <if test="deliverCount != null" >
        #{deliverCount,jdbcType=INTEGER},
      </if>
      <if test="price != null" >
        #{price,jdbcType=DOUBLE},
      </if>
      <if test="isRandom != null" >
        #{isRandom,jdbcType=INTEGER},
      </if>
      <if test="cdCategoryId != null" >
        #{cdCategoryId,jdbcType=INTEGER},
      </if>
      <if test="randomNum != null" >
        #{randomNum,jdbcType=INTEGER},
      </if>
      <if test="beginTime != null" >
        #{beginTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.xmomen.module.base.entity.CdPlanExample" resultType="java.lang.Integer" >
    select count(*) from cd_plan
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map" >
    update cd_plan
    <set >
      <if test="record.id != null" >
        ID = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.planName != null" >
        PLAN_NAME = #{record.planName,jdbcType=VARCHAR},
      </if>
      <if test="record.createUser != null" >
        CREATE_USER = #{record.createUser,jdbcType=VARCHAR},
      </if>
      <if test="record.createTime != null" >
        CREATE_TIME = #{record.createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.deliveryType != null" >
        DELIVERY_TYPE = #{record.deliveryType,jdbcType=INTEGER},
      </if>
      <if test="record.deliveryTime != null" >
        DELIVERY_TIME = #{record.deliveryTime,jdbcType=VARCHAR},
      </if>
      <if test="record.deliverCount != null" >
        DELIVER_COUNT = #{record.deliverCount,jdbcType=INTEGER},
      </if>
      <if test="record.price != null" >
        PRICE = #{record.price,jdbcType=DOUBLE},
      </if>
      <if test="record.isRandom != null" >
        IS_RANDOM = #{record.isRandom,jdbcType=INTEGER},
      </if>
      <if test="record.cdCategoryId != null" >
        CD_CATEGORY_ID = #{record.cdCategoryId,jdbcType=INTEGER},
      </if>
      <if test="record.randomNum != null" >
        RANDOM_NUM = #{record.randomNum,jdbcType=INTEGER},
      </if>
      <if test="record.beginTime != null" >
        BEGIN_TIME = #{record.beginTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
</mapper>