LiveMapper.xml 13.6 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.Live">
  <resultMap id="BaseResultMap" type="com.bjivt.entity.showtime.Live">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="user_id" jdbcType="INTEGER" property="userId" />
    <result column="record_addr" jdbcType="VARCHAR" property="recordAddr" />
    <result column="chatroom_addr" jdbcType="VARCHAR" property="chatroomAddr" />
    <result column="video_addr" jdbcType="VARCHAR" property="videoAddr" />
    <result column="audience_total_num" jdbcType="INTEGER" property="audienceTotalNum" />
    <result column="audience_now_num" jdbcType="INTEGER" property="audienceNowNum" />
    <result column="heartbeat" jdbcType="BIGINT" property="heartbeat" />
    <result column="like_num" jdbcType="INTEGER" property="likeNum" />
    <result column="tag" jdbcType="VARCHAR" property="tag" />
    <result column="is_allow_location" jdbcType="SMALLINT" property="isAllowLocation" />
    <result column="type" jdbcType="SMALLINT" property="type" />
    <result column="location" jdbcType="VARCHAR" property="location" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="ended_time" jdbcType="TIMESTAMP" property="endedTime" />
    <result column="recommend" jdbcType="INTEGER" property="recommend" />
    <result column="active" jdbcType="SMALLINT" property="active" />
    <result column="thumbnail" jdbcType="VARCHAR" property="thumbnail" />
  </resultMap>
  <sql id="Base_Column_List">
    id, name, user_id, record_addr, chatroom_addr, video_addr, audience_total_num, audience_now_num, 
    heartbeat, like_num, tag, is_allow_location, type, location, create_time, recommend, 
    active,thumbnail
  </sql>
  <select id="selectById" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from tbl_live_list
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteById" parameterType="java.lang.Integer">
    delete from tbl_live_list
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.bjivt.entity.showtime.Live">
    insert into tbl_live_list (id, name, user_id, 
      record_addr, chatroom_addr, video_addr, 
      audience_total_num, audience_now_num, heartbeat, 
      like_num, tag, is_allow_location, 
      type, location, create_time, 
      recommend, active)
    values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{userId,jdbcType=INTEGER}, 
      #{recordAddr,jdbcType=VARCHAR}, #{chatroomAddr,jdbcType=VARCHAR}, #{videoAddr,jdbcType=VARCHAR}, 
      #{audienceTotalNum,jdbcType=INTEGER}, #{audienceNowNum,jdbcType=INTEGER}, #{heartbeat,jdbcType=BIGINT}, 
      #{likeNum,jdbcType=INTEGER}, #{tag,jdbcType=VARCHAR}, #{isAllowLocation,jdbcType=SMALLINT}, 
      #{type,jdbcType=SMALLINT}, #{location,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, 
      #{recommend,jdbcType=INTEGER}, #{active,jdbcType=SMALLINT})
  </insert>
  <insert id="insertSelective" parameterType="com.bjivt.entity.showtime.Live">
    insert into tbl_live_list
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="name != null">
        name,
      </if>
      <if test="userId != null">
        user_id,
      </if>
      <if test="recordAddr != null">
        record_addr,
      </if>
      <if test="chatroomAddr != null">
        chatroom_addr,
      </if>
      <if test="videoAddr != null">
        video_addr,
      </if>
      <if test="audienceTotalNum != null">
        audience_total_num,
      </if>
      <if test="audienceNowNum != null">
        audience_now_num,
      </if>
      <if test="heartbeat != null">
        heartbeat,
      </if>
      <if test="likeNum != null">
        like_num,
      </if>
      <if test="tag != null">
        tag,
      </if>
      <if test="isAllowLocation != null">
        is_allow_location,
      </if>
      <if test="type != null">
        type,
      </if>
      <if test="location != null">
        location,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="recommend != null">
        recommend,
      </if>
      <if test="active != null">
        active,
      </if>
      <if test="endedTime != null">
            ended_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="userId != null">
        #{userId,jdbcType=INTEGER},
      </if>
      <if test="recordAddr != null">
        #{recordAddr,jdbcType=VARCHAR},
      </if>
      <if test="chatroomAddr != null">
        #{chatroomAddr,jdbcType=VARCHAR},
      </if>
      <if test="videoAddr != null">
        #{videoAddr,jdbcType=VARCHAR},
      </if>
      <if test="audienceTotalNum != null">
        #{audienceTotalNum,jdbcType=INTEGER},
      </if>
      <if test="audienceNowNum != null">
        #{audienceNowNum,jdbcType=INTEGER},
      </if>
      <if test="heartbeat != null">
        #{heartbeat,jdbcType=BIGINT},
      </if>
      <if test="likeNum != null">
        #{likeNum,jdbcType=INTEGER},
      </if>
      <if test="tag != null">
        #{tag,jdbcType=VARCHAR},
      </if>
      <if test="isAllowLocation != null">
        #{isAllowLocation,jdbcType=SMALLINT},
      </if>
      <if test="type != null">
        #{type,jdbcType=SMALLINT},
      </if>
      <if test="location != null">
        #{location,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="recommend != null">
        #{recommend,jdbcType=INTEGER},
      </if>
      <if test="active != null">
        #{active,jdbcType=SMALLINT},
      </if>
      <if test="endedTime != null">
            #{endedTime,jdbcType=TIMESTAMP},
       </if>
    </trim>
  </insert>
  <update id="updateByIdSelective" parameterType="com.bjivt.entity.showtime.Live">
    update tbl_live_list
    <set>
      <if test="name != null">
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="userId != null">
        user_id = #{userId,jdbcType=INTEGER},
      </if>
      <if test="recordAddr != null">
        record_addr = #{recordAddr,jdbcType=VARCHAR},
      </if>
      <if test="chatroomAddr != null">
        chatroom_addr = #{chatroomAddr,jdbcType=VARCHAR},
      </if>
      <if test="videoAddr != null">
        video_addr = #{videoAddr,jdbcType=VARCHAR},
      </if>
      <if test="audienceTotalNum != null">
        audience_total_num = #{audienceTotalNum,jdbcType=INTEGER},
      </if>
      <if test="audienceNowNum != null">
        audience_now_num = #{audienceNowNum,jdbcType=INTEGER},
      </if>
      <if test="heartbeat != null">
        heartbeat = #{heartbeat,jdbcType=BIGINT},
      </if>
      <if test="likeNum != null">
        like_num = #{likeNum,jdbcType=INTEGER},
      </if>
      <if test="tag != null">
        tag = #{tag,jdbcType=VARCHAR},
      </if>
      <if test="isAllowLocation != null">
        is_allow_location = #{isAllowLocation,jdbcType=SMALLINT},
      </if>
      <if test="type != null">
        type = #{type,jdbcType=SMALLINT},
      </if>
      <if test="location != null">
        location = #{location,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="recommend != null">
        recommend = #{recommend,jdbcType=INTEGER},
      </if>
      <if test="active != null">
        active = #{active,jdbcType=SMALLINT},
      </if>
      <if test="endedTime != null">
        ended_time = #{endedTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateById" parameterType="com.bjivt.entity.showtime.Live">
    update tbl_live_list
    set name = #{name,jdbcType=VARCHAR},
      user_id = #{userId,jdbcType=INTEGER},
      record_addr = #{recordAddr,jdbcType=VARCHAR},
      chatroom_addr = #{chatroomAddr,jdbcType=VARCHAR},
      video_addr = #{videoAddr,jdbcType=VARCHAR},
      audience_total_num = #{audienceTotalNum,jdbcType=INTEGER},
      audience_now_num = #{audienceNowNum,jdbcType=INTEGER},
      heartbeat = #{heartbeat,jdbcType=BIGINT},
      like_num = #{likeNum,jdbcType=INTEGER},
      tag = #{tag,jdbcType=VARCHAR},
      is_allow_location = #{isAllowLocation,jdbcType=SMALLINT},
      type = #{type,jdbcType=SMALLINT},
      location = #{location,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      recommend = #{recommend,jdbcType=INTEGER},
      active = #{active,jdbcType=SMALLINT},
      ended_time = #{endedTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>
  
  <select id="getCountBy" resultType="java.lang.Integer" parameterType="com.bjivt.entity.showtime.Live">
    SELECT
				count(id)
			FROM
				tbl_live_list
    <trim prefix="where" prefixOverrides="and|or">
			      <if test="userId != null and userId != ''" >
		        	 and   tbl_live_list.user_id = #{userId}
		    	  </if>
      			<if test="name != null and name != ''" >
		        	 and   from_base64(tbl_live_list.name) like '%${name}%'
		    	  </if>
		  	  	 <if test="recommend!= null and recommend!= ''" >
		        	 and   tbl_live_list.recommend = #{recommend}
		    	  </if>
      </trim>
  </select>
  
     <select id="findListByMap" resultMap="BaseResultMap" parameterType="java.util.Map">
         SELECT
				<include refid="Base_Column_List"/>
			FROM
				tbl_live_list
  	  	<trim prefix="where" prefixOverrides="and|or">
		  	  	 <if test="Live.userId!= null and Live.userId!= ''" >
		        	 and   tbl_live_list.user_id = #{Live.userId}
		    	 </if>
		  	  	 <if test="Live.recommend!= null and Live.recommend!= ''" >
		        	 and   tbl_live_list.recommend = #{Live.recommend}
		    	 </if>
		  	  	 <if test="Live.name!=null and Live.name!= ''" >
		        	 and   from_base64(tbl_live_list.name) like '%${Live.name}%'
		    	 </if>
		    	 <if test="startTime != null and startTime !=''  and endTime != null and endTime !=''">
					and date_format(tbl_live_list.create_time,'%Y-%m-%d') between str_to_date(#{startTime},'%Y-%m-%d') and str_to_date(#{endTime},'%Y-%m-%d')
				 </if>
  	  	</trim>
  	  	order by create_time DESC
	    <if test="page != null and page !=''">
	    <if test="page.from != null and page.size != null">
          limit #{page.from},#{page.size}
   		</if>
   		</if>
  </select>
  
  <select id="getStarLiveCountBy" resultType="java.lang.Integer" parameterType="com.bjivt.entity.showtime.Live">
    SELECT
				count(tbl.id)
			FROM
				tbl_live_list tbl
				LEFT JOIN tbl_user_list tbu ON tbu.id = tbl.user_id
				where 1=1
		  	  	 <if test="userId!= null and userId!= ''" >
		        	 and   tbl.user_id = #{userId}
		    	  </if>
		  	  	 <if test="recommend!= null and recommend!= ''" >
		        	 and   tbl.recommend = #{recommend}
		    	  </if>
		  	  	 <if test="name!=null and name!= ''" >
		        	 and   from_base64(tbl.name) like '%${name}%'
		    	  </if>
  </select>
  
     <select id="findStarLiveListByPage" resultMap="BaseResultMap" parameterType="java.util.Map">
         SELECT
			tbl.id, tbl.name, tbl.user_id, tbl.record_addr, tbl.chatroom_addr, tbl.video_addr, tbl.audience_total_num, tbl.audience_now_num, 
		    tbl.heartbeat, tbl.like_num, tbl.tag, tbl.is_allow_location, tbl.type, tbl.location, tbl.create_time, tbl.recommend, 
		    tbl.active
			FROM
				tbl_live_list tbl
				LEFT JOIN tbl_user_list tbu ON tbu.id = tbl.user_id
				where 1=1
		  	  	 <if test="Live.userId!= null and Live.userId!= ''" >
		        	 and   tbl.user_id = #{Live.userId}
		    	  </if>
		  	  	 <if test="Live.recommend!= null and Live.recommend!= ''" >
		        	 and   tbl.recommend = #{Live.recommend}
		    	  </if>
		  	  	 <if test="Live.name!=null and Live.name!= ''" >
		        	 and   from_base64(tbl.name) like '%${Live.name}%'
		    	  </if>
  	  	order by tbl.create_time DESC
	    <if test="page != null and page !=''">
	    <if test="page.from != null and page.size != null">
          limit #{page.from},#{page.size}
   		</if>
   		</if>
  </select>
  
  
  <select id="findLiveListByPage" resultMap="BaseResultMap" parameterType="java.util.Map">
         SELECT
			tbl.id, tbl.name, tbl.user_id, tbl.record_addr, tbl.chatroom_addr, tbl.video_addr, tbl.audience_total_num, tbl.audience_now_num, 
		    tbl.heartbeat, tbl.like_num, tbl.tag, tbl.is_allow_location, tbl.type, tbl.location, tbl.create_time, tbl.recommend, tbl.ended_time,
		    tbl.active
			FROM
				tbl_live_list tbl
				LEFT JOIN tbl_user_list tbu ON tbu.id = tbl.user_id
				where 1=1
		  	  	 <if test="Live.userId!= null and Live.userId!= ''" >
		        	 and   tbl.user_id = #{Live.userId}
		    	  </if>
		  	  	 <if test="Live.recommend!= null and Live.recommend!= ''" >
		        	 and   tbl.recommend = #{Live.recommend}
		    	  </if>
		  	  	 <if test="Live.name!=null and Live.name!= ''" >
		        	 and   from_base64(tbl.name) like '%${Live.name}%'
		    	  </if>
		    	  <if test="startTime!=null and startTime!=''">
		    	  		and
		    		 	<![CDATA[date_format(tbl.create_time,'%Y-%m-%d') >= str_to_date(#{startTime},'%Y-%m-%d') ]]>
		 				<![CDATA[and date_format(tbl.create_time,'%Y-%m-%d') <= str_to_date(#{endTime},'%Y-%m-%d')]]>
		    	  </if>
  	  	order by tbl.create_time DESC
	    <if test="page != null and page !=''">
	    <if test="page.from != null and page.size != null">
          limit #{page.from},#{page.size}
   		</if>
   		</if>
  </select>
</mapper>