ActPrizeProductUserMapper.xml 7.06 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.activity.dal.ActPrizeProductUserMapper">
  <resultMap id="BaseResultMap" type="com.yoho.activity.dal.model.ActPrizeProductUser">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="act_id" jdbcType="INTEGER" property="actId" />
    <result column="act_prize_id" jdbcType="INTEGER" property="actPrizeId" />
    <result column="uid" jdbcType="INTEGER" property="uid" />
    <result column="user_name" jdbcType="VARCHAR" property="userName" />
    <result column="user_thumb" jdbcType="VARCHAR" property="userThumb" />
    <result column="union_id" jdbcType="VARCHAR" property="unionId" />
    <result column="prize_code" jdbcType="VARCHAR" property="prizeCode" />
    <result column="is_share_take" jdbcType="TINYINT" property="isShareTake" />
    <result column="share_uid" jdbcType="INTEGER" property="shareUid" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  </resultMap>
  <sql id="Base_Column_List">
    id, act_id, act_prize_id, uid, user_name, user_thumb, union_id, prize_code, is_share_take, 
    share_uid, create_time
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from act_prize_product_user
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from act_prize_product_user
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.yoho.activity.dal.model.ActPrizeProductUser">
    insert into act_prize_product_user (id, act_id, act_prize_id, 
      uid, user_name, user_thumb, 
      union_id, prize_code, is_share_take, 
      share_uid, create_time)
    values (#{id,jdbcType=INTEGER}, #{actId,jdbcType=INTEGER}, #{actPrizeId,jdbcType=INTEGER}, 
      #{uid,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR}, #{userThumb,jdbcType=VARCHAR}, 
      #{unionId,jdbcType=VARCHAR}, #{prizeCode,jdbcType=VARCHAR}, #{isShareTake,jdbcType=TINYINT}, 
      #{shareUid,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.yoho.activity.dal.model.ActPrizeProductUser">
    insert into act_prize_product_user
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="actId != null">
        act_id,
      </if>
      <if test="actPrizeId != null">
        act_prize_id,
      </if>
      <if test="uid != null">
        uid,
      </if>
      <if test="userName != null">
        user_name,
      </if>
      <if test="userThumb != null">
        user_thumb,
      </if>
      <if test="unionId != null">
        union_id,
      </if>
      <if test="prizeCode != null">
        prize_code,
      </if>
      <if test="isShareTake != null">
        is_share_take,
      </if>
      <if test="shareUid != null">
        share_uid,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="actId != null">
        #{actId,jdbcType=INTEGER},
      </if>
      <if test="actPrizeId != null">
        #{actPrizeId,jdbcType=INTEGER},
      </if>
      <if test="uid != null">
        #{uid,jdbcType=INTEGER},
      </if>
      <if test="userName != null">
        #{userName,jdbcType=VARCHAR},
      </if>
      <if test="userThumb != null">
        #{userThumb,jdbcType=VARCHAR},
      </if>
      <if test="unionId != null">
        #{unionId,jdbcType=VARCHAR},
      </if>
      <if test="prizeCode != null">
        #{prizeCode,jdbcType=VARCHAR},
      </if>
      <if test="isShareTake != null">
        #{isShareTake,jdbcType=TINYINT},
      </if>
      <if test="shareUid != null">
        #{shareUid,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yoho.activity.dal.model.ActPrizeProductUser">
    update act_prize_product_user
    <set>
      <if test="actId != null">
        act_id = #{actId,jdbcType=INTEGER},
      </if>
      <if test="actPrizeId != null">
        act_prize_id = #{actPrizeId,jdbcType=INTEGER},
      </if>
      <if test="uid != null">
        uid = #{uid,jdbcType=INTEGER},
      </if>
      <if test="userName != null">
        user_name = #{userName,jdbcType=VARCHAR},
      </if>
      <if test="userThumb != null">
        user_thumb = #{userThumb,jdbcType=VARCHAR},
      </if>
      <if test="unionId != null">
        union_id = #{unionId,jdbcType=VARCHAR},
      </if>
      <if test="prizeCode != null">
        prize_code = #{prizeCode,jdbcType=VARCHAR},
      </if>
      <if test="isShareTake != null">
        is_share_take = #{isShareTake,jdbcType=TINYINT},
      </if>
      <if test="shareUid != null">
        share_uid = #{shareUid,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yoho.activity.dal.model.ActPrizeProductUser">
    update act_prize_product_user
    set act_id = #{actId,jdbcType=INTEGER},
      act_prize_id = #{actPrizeId,jdbcType=INTEGER},
      uid = #{uid,jdbcType=INTEGER},
      user_name = #{userName,jdbcType=VARCHAR},
      user_thumb = #{userThumb,jdbcType=VARCHAR},
      union_id = #{unionId,jdbcType=VARCHAR},
      prize_code = #{prizeCode,jdbcType=VARCHAR},
      is_share_take = #{isShareTake,jdbcType=TINYINT},
      share_uid = #{shareUid,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <select id="selectRecentUsers" resultMap="BaseResultMap">
    select uid, user_name, user_thumb, create_time from act_prize_product_user
    where act_prize_id = #{actPrizeId} and is_share_take=0 order by create_time desc limit 10
  </select>

    <select id="getActUserCodeCount" resultType="java.lang.Integer">
      SELECT count(1) from act_prize_product_user where 1=1
      <if test="record.actPrizeId != null">
          and act_prize_id = #{actPrizeId}
      </if>
      <if test="record.actPrizeId != null">
          and uid = #{uid}
      </if>
    </select>

  <insert id="insertSelective" parameterType="com.yoho.activity.dal.model.ActPrizeProductUser">
    insert into act_prize_product_user (act_prize_id, uid, user_name, user_thumb, union_id, prize_code, is_share_take, share_uid)
    select #{record.actPrizeId} as act_prize_id, #{record.uid} as uid, #{record.userName}, #{record.userThumb}, #{record.unionId}, #{record.prizeCode} as prize_code,
                #{record.isShareTake} as is_share_take, #{record.shareUid} as share_uid from act_prize_product_user where uid = #{record.uid} and is_share_take=0  limit 1;
  </insert>
</mapper>