ChannelUserMapper.xml 12.9 KB
<?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.yoho.unions.dal.IChannelUserDAO" >
  <resultMap id="BaseResultMap" type="com.yoho.unions.dal.model.ChannelUser" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="mobile" property="mobile" jdbcType="VARCHAR" />
    <result column="channel_source" property="channelSource" jdbcType="INTEGER" />
    <result column="channel_purchases_number" property="channelPurchasesNumber" jdbcType="SMALLINT" />
    <result column="channel_order_code" property="channelOrderCode" jdbcType="VARCHAR" />
    <result column="channel_order_time" property="channelOrderTime" jdbcType="INTEGER" />
    <result column="channel_order_amount" property="channelOrderAmount" jdbcType="DECIMAL" />
    <result column="uid" property="uid" jdbcType="INTEGER" />
    <result column="yh_purchases_number" property="yhPurchasesNumber" jdbcType="SMALLINT" />
    <result column="yh_order_code" property="yhOrderCode" jdbcType="VARCHAR" />
    <result column="yh_order_time" property="yhOrderTime" jdbcType="INTEGER" />
    <result column="yh_order_amount" property="yhOrderAmount" jdbcType="DECIMAL" />
    <result column="union_code" property="unionCode" jdbcType="VARCHAR" />
    <result column="user_channel" property="userChannel" jdbcType="VARCHAR" />
    <result column="register_time" property="registerTime" jdbcType="INTEGER" />
    <result column="sms_number" property="smsNumber" jdbcType="SMALLINT" />
    <result column="sms_time" property="smsTime" jdbcType="INTEGER" />
    <result column="create_time" property="createTime" jdbcType="INTEGER" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, mobile, channel_source, channel_purchases_number, channel_order_code, channel_order_time, 
    channel_order_amount, uid, yh_purchases_number, yh_order_code, yh_order_time, yh_order_amount,
    union_code, user_channel, register_time, sms_number, sms_time, create_time
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from channel_user
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from channel_user
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.yoho.unions.dal.model.ChannelUser" >
    insert into channel_user (id, mobile, channel_source, 
      channel_purchases_number, channel_order_code, 
      channel_order_time, channel_order_amount, uid,
      yh_purchases_number, yh_order_code, yh_order_time, 
      yh_order_amount, union_code, user_channel, 
      register_time, sms_number, sms_time, 
      create_time)
    values (#{id,jdbcType=INTEGER}, #{mobile,jdbcType=VARCHAR}, #{channelSource,jdbcType=INTEGER}, 
      #{channelPurchasesNumber,jdbcType=SMALLINT}, #{channelOrderCode,jdbcType=VARCHAR}, 
      #{channelOrderTime,jdbcType=INTEGER}, #{channelOrderAmount,jdbcType=DECIMAL}, #{uid,jdbcType=INTEGER},
      #{yhPurchasesNumber,jdbcType=SMALLINT}, #{yhOrderCode,jdbcType=VARCHAR}, #{yhOrderTime,jdbcType=INTEGER}, 
      #{yhOrderAmount,jdbcType=DECIMAL}, #{unionCode,jdbcType=VARCHAR}, #{userChannel,jdbcType=VARCHAR}, 
      #{registerTime,jdbcType=INTEGER}, #{smsNumber,jdbcType=SMALLINT}, #{smsTime,jdbcType=INTEGER}, 
      #{createTime,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.yoho.unions.dal.model.ChannelUser" >
    insert into channel_user
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="mobile != null" >
        mobile,
      </if>
      <if test="channelSource != null" >
        channel_source,
      </if>
      <if test="channelPurchasesNumber != null" >
        channel_purchases_number,
      </if>
      <if test="channelOrderCode != null" >
        channel_order_code,
      </if>
      <if test="channelOrderTime != null" >
        channel_order_time,
      </if>
      <if test="channelOrderAmount != null" >
        channel_order_amount,
      </if>
      <if test="uid != null" >
        uid,
      </if>
      <if test="yhPurchasesNumber != null" >
        yh_purchases_number,
      </if>
      <if test="yhOrderCode != null" >
        yh_order_code,
      </if>
      <if test="yhOrderTime != null" >
        yh_order_time,
      </if>
      <if test="yhOrderAmount != null" >
        yh_order_amount,
      </if>
      <if test="unionCode != null" >
        union_code,
      </if>
      <if test="userChannel != null" >
        user_channel,
      </if>
      <if test="registerTime != null" >
        register_time,
      </if>
      <if test="smsNumber != null" >
        sms_number,
      </if>
      <if test="smsTime != null" >
        sms_time,
      </if>
      <if test="createTime != null" >
        create_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="mobile != null" >
        #{mobile,jdbcType=VARCHAR},
      </if>
      <if test="channelSource != null" >
        #{channelSource,jdbcType=INTEGER},
      </if>
      <if test="channelPurchasesNumber != null" >
        #{channelPurchasesNumber,jdbcType=SMALLINT},
      </if>
      <if test="channelOrderCode != null" >
        #{channelOrderCode,jdbcType=VARCHAR},
      </if>
      <if test="channelOrderTime != null" >
        #{channelOrderTime,jdbcType=INTEGER},
      </if>
      <if test="channelOrderAmount != null" >
        #{channelOrderAmount,jdbcType=DECIMAL},
      </if>
      <if test="uid != null" >
        #{uid,jdbcType=INTEGER},
      </if>
      <if test="yhPurchasesNumber != null" >
        #{yhPurchasesNumber,jdbcType=SMALLINT},
      </if>
      <if test="yhOrderCode != null" >
        #{yhOrderCode,jdbcType=VARCHAR},
      </if>
      <if test="yhOrderTime != null" >
        #{yhOrderTime,jdbcType=INTEGER},
      </if>
      <if test="yhOrderAmount != null" >
        #{yhOrderAmount,jdbcType=DECIMAL},
      </if>
      <if test="unionCode != null" >
        #{unionCode,jdbcType=VARCHAR},
      </if>
      <if test="userChannel != null" >
        #{userChannel,jdbcType=VARCHAR},
      </if>
      <if test="registerTime != null" >
        #{registerTime,jdbcType=INTEGER},
      </if>
      <if test="smsNumber != null" >
        #{smsNumber,jdbcType=SMALLINT},
      </if>
      <if test="smsTime != null" >
        #{smsTime,jdbcType=INTEGER},
      </if>
      <if test="createTime != null" >
        #{createTime,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yoho.unions.dal.model.ChannelUser" >
    update channel_user
    <set >
      <if test="mobile != null" >
        mobile = #{mobile,jdbcType=VARCHAR},
      </if>
      <if test="channelSource != null" >
        channel_source = #{channelSource,jdbcType=INTEGER},
      </if>
      <if test="channelPurchasesNumber != null" >
        channel_purchases_number = #{channelPurchasesNumber,jdbcType=SMALLINT},
      </if>
      <if test="channelOrderCode != null" >
        channel_order_code = #{channelOrderCode,jdbcType=VARCHAR},
      </if>
      <if test="channelOrderTime != null" >
        channel_order_time = #{channelOrderTime,jdbcType=INTEGER},
      </if>
      <if test="channelOrderAmount != null" >
        channel_order_amount = #{channelOrderAmount,jdbcType=DECIMAL},
      </if>
      <if test="uid != null" >
        uid = #{uid,jdbcType=INTEGER},
      </if>
      <if test="yhPurchasesNumber != null" >
        yh_purchases_number = #{yhPurchasesNumber,jdbcType=SMALLINT},
      </if>
      <if test="yhOrderCode != null" >
        yh_order_code = #{yhOrderCode,jdbcType=VARCHAR},
      </if>
      <if test="yhOrderTime != null" >
        yh_order_time = #{yhOrderTime,jdbcType=INTEGER},
      </if>
      <if test="yhOrderAmount != null" >
        yh_order_amount = #{yhOrderAmount,jdbcType=DECIMAL},
      </if>
      <if test="unionCode != null" >
        union_code = #{unionCode,jdbcType=VARCHAR},
      </if>
      <if test="userChannel != null" >
        user_channel = #{userChannel,jdbcType=VARCHAR},
      </if>
      <if test="registerTime != null" >
        register_time = #{registerTime,jdbcType=INTEGER},
      </if>
      <if test="smsNumber != null" >
        sms_number = #{smsNumber,jdbcType=SMALLINT},
      </if>
      <if test="smsTime != null" >
        sms_time = #{smsTime,jdbcType=INTEGER},
      </if>
      <if test="createTime != null" >
        create_time = #{createTime,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yoho.unions.dal.model.ChannelUser" >
    update channel_user
    set mobile = #{mobile,jdbcType=VARCHAR},
      channel_source = #{channelSource,jdbcType=INTEGER},
      channel_purchases_number = #{channelPurchasesNumber,jdbcType=SMALLINT},
      channel_order_code = #{channelOrderCode,jdbcType=VARCHAR},
      channel_order_time = #{channelOrderTime,jdbcType=INTEGER},
      channel_order_amount = #{channelOrderAmount,jdbcType=DECIMAL},
      uid = #{uid,jdbcType=INTEGER},
      yh_purchases_number = #{yhPurchasesNumber,jdbcType=SMALLINT},
      yh_order_code = #{yhOrderCode,jdbcType=VARCHAR},
      yh_order_time = #{yhOrderTime,jdbcType=INTEGER},
      yh_order_amount = #{yhOrderAmount,jdbcType=DECIMAL},
      union_code = #{unionCode,jdbcType=VARCHAR},
      user_channel = #{userChannel,jdbcType=VARCHAR},
      register_time = #{registerTime,jdbcType=INTEGER},
      sms_number = #{smsNumber,jdbcType=SMALLINT},
      sms_time = #{smsTime,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <select id="selectCount" resultType="java.lang.Integer">
    SELECT count(*) FROM channel_user c
    <include refid="WHERE_CONDITION"/>
  </select>

  <select id="selectPage" resultMap="BaseResultMap">
    SELECT <include refid="Base_Column_List" /> FROM channel_user c
    <include refid="WHERE_CONDITION"/>
    ORDER BY create_time DESC
    limit #{offset}, #{rows}
  </select>

  <sql id="WHERE_CONDITION">
    <if test="condition != null">
      <trim prefix="where" prefixOverrides="and | or">
        1 = 1
        <if test="condition.channelSource != null">
          and channel_source in (${condition.channelSource})
        </if>
        <if test="condition.channelOrderCode != null">
          AND channel_order_code like CONCAT('%', #{condition.channelOrderCode}, '%')
        </if>
        <if test="condition.beginChannelOrderTime != null">
          AND channel_order_time >= #{condition.beginChannelOrderTime}
        </if>
        <if test="condition.endChannelOrderTime != null">
          <![CDATA[ AND channel_order_time <= #{condition.endChannelOrderTime} ]]>
        </if>
        <if test="condition.uid != null">
          AND uid = #{condition.uid}
        </if>
        <choose>
          <when test="condition.hasUid != null and condition.hasUid == 0">
            and (uid = 0 or uid is null)
          </when>
          <when test="condition.hasUid != null and condition.hasUid == 1">
            and uid > 0
          </when>
        </choose>
        <choose>
          <when test="condition.hasYHOrder != null and condition.hasYHOrder == 0">
            and (yh_order_code = '' or yh_order_code is null)
          </when>
          <when test="condition.hasYHOrder != null and condition.hasYHOrder == 1">
            and (yh_order_code != '' or yh_order_code is not null)
          </when>
        </choose>
        <if test="condition.yhOrderCode != null">
          AND yh_order_code = like CONCAT('%', #{condition.yhOrderCode}, '%')
        </if>
        <if test="condition.beginYHOrderTime != null">
          AND yh_order_time >= #{condition.beginYHOrderTime}
        </if>
        <if test="condition.endYHOrderTime != null">
          <![CDATA[ AND yh_order_time <= #{condition.endYHOrderTime} ]]>
        </if>
        <if test="condition.unionCode != null">
          AND union_code = #{condition.unionCode}
        </if>
        <if test="condition.userChannel != null">
          AND user_channel = #{condition.userChannel}
        </if>
        <if test="condition.beginRegisterTime != null">
          AND register_time >= #{condition.beginRegisterTime}
        </if>
        <if test="condition.endRegisterTime != null">
          <![CDATA[ AND register_time <= #{condition.endRegisterTime} ]]>
        </if>
        <if test="condition.beginSmsTime != null">
          AND sms_time >= #{condition.beginSmsTime}
        </if>
        <if test="condition.endSmsTime != null">
          <![CDATA[ AND sms_time <= #{condition.endSmsTime} ]]>
        </if>
        <if test="condition.ids != null">
          and id in
          <foreach item="item" index="index" collection="condition.ids" open="(" separator="," close=")">
          #{item}
        </foreach>
        </if>
      </trim>
    </if>
  </sql>

</mapper>