GiftDetailMapper.xml 5.08 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.bjivt.entity.showtime.GiftDetail">
  <resultMap id="BaseResultMap" type="com.bjivt.entity.showtime.GiftDetail">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="from_user_id" jdbcType="INTEGER" property="fromUserId" />
    <result column="to_user_id" jdbcType="INTEGER" property="toUserId" />
    <result column="live_id" jdbcType="INTEGER" property="liveId" />
    <result column="gift_id" jdbcType="INTEGER" property="giftId" />
    <result column="count" jdbcType="INTEGER" property="count" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  </resultMap>
  <sql id="Base_Column_List">
    id, from_user_id, to_user_id, live_id, gift_id, count, create_time
  </sql>
  <select id="selectById" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from tbl_user_gift_detail
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteById" parameterType="java.lang.Integer">
    delete from tbl_user_gift_detail
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.bjivt.entity.showtime.GiftDetail">
    insert into tbl_user_gift_detail (id, from_user_id, to_user_id, 
      live_id, gift_id, count, 
      create_time)
    values (#{id,jdbcType=INTEGER}, #{fromUserId,jdbcType=INTEGER}, #{toUserId,jdbcType=INTEGER}, 
      #{liveId,jdbcType=INTEGER}, #{giftId,jdbcType=INTEGER}, #{count,jdbcType=INTEGER}, 
      #{createTime,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.bjivt.entity.showtime.GiftDetail">
    insert into tbl_user_gift_detail
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="fromUserId != null">
        from_user_id,
      </if>
      <if test="toUserId != null">
        to_user_id,
      </if>
      <if test="liveId != null">
        live_id,
      </if>
      <if test="giftId != null">
        gift_id,
      </if>
      <if test="count != null">
        count,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="fromUserId != null">
        #{fromUserId,jdbcType=INTEGER},
      </if>
      <if test="toUserId != null">
        #{toUserId,jdbcType=INTEGER},
      </if>
      <if test="liveId != null">
        #{liveId,jdbcType=INTEGER},
      </if>
      <if test="giftId != null">
        #{giftId,jdbcType=INTEGER},
      </if>
      <if test="count != null">
        #{count,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByIdSelective" parameterType="com.bjivt.entity.showtime.GiftDetail">
    update tbl_user_gift_detail
    <set>
      <if test="fromUserId != null">
        from_user_id = #{fromUserId,jdbcType=INTEGER},
      </if>
      <if test="toUserId != null">
        to_user_id = #{toUserId,jdbcType=INTEGER},
      </if>
      <if test="liveId != null">
        live_id = #{liveId,jdbcType=INTEGER},
      </if>
      <if test="giftId != null">
        gift_id = #{giftId,jdbcType=INTEGER},
      </if>
      <if test="count != null">
        count = #{count,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateById" parameterType="com.bjivt.entity.showtime.GiftDetail">
    update tbl_user_gift_detail
    set from_user_id = #{fromUserId,jdbcType=INTEGER},
      to_user_id = #{toUserId,jdbcType=INTEGER},
      live_id = #{liveId,jdbcType=INTEGER},
      gift_id = #{giftId,jdbcType=INTEGER},
      count = #{count,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>
  
   <select id="getCountBy" resultType="java.lang.Integer" parameterType="com.bjivt.entity.showtime.GiftDetail">
    SELECT
				count(1)
			FROM
				tbl_user_gift_detail
    <trim prefix="where" prefixOverrides="and|or">
      <if test="liveId != null and liveId != ''" >
		        	 and   tbl_user_gift_detail.live_id = #{liveId}
		    	  </if>
      </trim>
  </select>
  
     <select id="findListByMap" resultMap="BaseResultMap" parameterType="java.util.Map">
     	SELECT
				<include refid="Base_Column_List"/>
			FROM
				tbl_user_gift_detail
  	  	<trim prefix="where" prefixOverrides="and|or">
		  	  	 <if test="GiftDetail.liveId != null and GiftDetail.liveId != ''" >
		        	 and   tbl_user_gift_detail.live_id = #{GiftDetail.liveId}
		    	  </if>
  	  	</trim>
  	  	order by create_time
	    <if test="page != null and page !=''">
	    <if test="page.from != null and page.size != null">
          limit #{page.from},#{page.size}
   		</if>
   		</if>
  </select>
</mapper>