RedEnvelopMapper.xml 5.82 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.RedEnvelop">
  <resultMap id="BaseResultMap" type="com.bjivt.entity.showtime.RedEnvelop">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="live_id" jdbcType="INTEGER" property="liveId" />
    <result column="user_id" jdbcType="INTEGER" property="userId" />
    <result column="money" jdbcType="INTEGER" property="money" />
    <result column="request_money" jdbcType="INTEGER" property="requestMoney" />
    <result column="request_num" jdbcType="INTEGER" property="requestNum" />
    <result column="state" jdbcType="SMALLINT" property="state" />
    <result column="count" jdbcType="INTEGER" property="count" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  </resultMap>
  <sql id="Base_Column_List">
    id, live_id, user_id, money, request_money, request_num, state, count, create_time
  </sql>
  <select id="selectById" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from tbl_red_envelop
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteById" parameterType="java.lang.Integer">
    delete from tbl_red_envelop
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.bjivt.entity.showtime.RedEnvelop">
    insert into tbl_red_envelop (id, live_id, user_id, 
      money, request_money, request_num, 
      state, count, create_time
      )
    values (#{id,jdbcType=INTEGER}, #{liveId,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, 
      #{money,jdbcType=INTEGER}, #{requestMoney,jdbcType=INTEGER}, #{requestNum,jdbcType=INTEGER}, 
      #{state,jdbcType=SMALLINT}, #{count,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.bjivt.entity.showtime.RedEnvelop">
    insert into tbl_red_envelop
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="liveId != null">
        live_id,
      </if>
      <if test="userId != null">
        user_id,
      </if>
      <if test="money != null">
        money,
      </if>
      <if test="requestMoney != null">
        request_money,
      </if>
      <if test="requestNum != null">
        request_num,
      </if>
      <if test="state != null">
        state,
      </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="liveId != null">
        #{liveId,jdbcType=INTEGER},
      </if>
      <if test="userId != null">
        #{userId,jdbcType=INTEGER},
      </if>
      <if test="money != null">
        #{money,jdbcType=INTEGER},
      </if>
      <if test="requestMoney != null">
        #{requestMoney,jdbcType=INTEGER},
      </if>
      <if test="requestNum != null">
        #{requestNum,jdbcType=INTEGER},
      </if>
      <if test="state != null">
        #{state,jdbcType=SMALLINT},
      </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.RedEnvelop">
    update tbl_red_envelop
    <set>
      <if test="liveId != null">
        live_id = #{liveId,jdbcType=INTEGER},
      </if>
      <if test="userId != null">
        user_id = #{userId,jdbcType=INTEGER},
      </if>
      <if test="money != null">
        money = #{money,jdbcType=INTEGER},
      </if>
      <if test="requestMoney != null">
        request_money = #{requestMoney,jdbcType=INTEGER},
      </if>
      <if test="requestNum != null">
        request_num = #{requestNum,jdbcType=INTEGER},
      </if>
      <if test="state != null">
        state = #{state,jdbcType=SMALLINT},
      </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.RedEnvelop">
    update tbl_red_envelop
    set live_id = #{liveId,jdbcType=INTEGER},
      user_id = #{userId,jdbcType=INTEGER},
      money = #{money,jdbcType=INTEGER},
      request_money = #{requestMoney,jdbcType=INTEGER},
      request_num = #{requestNum,jdbcType=INTEGER},
      state = #{state,jdbcType=SMALLINT},
      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.RedEnvelop">
    SELECT
				count(1)
			FROM
				tbl_red_envelop
    <trim prefix="where" prefixOverrides="and|or">
      <if test="liveId != null and liveId != ''" >
		        	 and   tbl_red_envelop.live_id = #{liveId}
		    	  </if>
      </trim>
  </select>
  
     <select id="findListByMap" resultMap="BaseResultMap" parameterType="java.util.Map">
     	SELECT
				<include refid="Base_Column_List"/>
			FROM
				tbl_red_envelop
  	  	<trim prefix="where" prefixOverrides="and|or">
		  	  	 <if test="RedEnvelop.liveId!= null and RedEnvelop.liveId!= ''" >
		        	 and   tbl_red_envelop.live_id = #{RedEnvelop.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>