<?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.cab.dao.CabLiveContentMapper" >
  <resultMap id="BaseResultMap" type="com.cab.model.CabLiveContent" >
    <id column="content_id" property="contentId" jdbcType="INTEGER" />
    <result column="content_title" property="contentTitle" jdbcType="VARCHAR" />
    <result column="create_Date" property="createDate" jdbcType="DATE" />
    <result column="end_date" property="endDate" jdbcType="DATE" />
    <result column="preheat_date" property="preheatDate" jdbcType="DATE" />
    <result column="preheat_img" property="preheatImg" jdbcType="VARCHAR" />
    <result column="start_date" property="startDate" jdbcType="DATE" />
    <result column="status" property="status" jdbcType="VARCHAR" />
    <result column="thumb_min_url" property="thumbMinUrl" jdbcType="VARCHAR" />
    <result column="thumb_url" property="thumbUrl" jdbcType="VARCHAR" />
    <result column="user_count" property="userCount" jdbcType="INTEGER" />
    <result column="user_id" property="userId" jdbcType="INTEGER" />
    <result column="video_time" property="videoTime" jdbcType="VARCHAR" />
    <result column="video_url" property="videoUrl" jdbcType="VARCHAR" />
  </resultMap>
  <resultMap id="ResultMapWithBLOBs" type="com.cab.model.CabLiveContent" extends="BaseResultMap" >
    <result column="content_detail" property="contentDetail" jdbcType="LONGVARCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    content_id, content_title, create_Date, end_date, preheat_date, preheat_img, start_date, 
    status, thumb_min_url, thumb_url, user_count, user_id, video_time, video_url
  </sql>
  <sql id="Blob_Column_List" >
    content_detail
  </sql>
  <select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from cab_live_content
    where content_id = #{contentId,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from cab_live_content
    where content_id = #{contentId,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.cab.model.CabLiveContent" useGeneratedKeys="true" keyProperty="content_id">
    insert into cab_live_content (content_id, content_title, create_Date, 
      end_date, preheat_date, preheat_img, 
      start_date, status, thumb_min_url, 
      thumb_url, user_count, user_id, 
      video_time, video_url, content_detail
      )
    values (#{contentId,jdbcType=INTEGER}, #{contentTitle,jdbcType=VARCHAR}, #{createDate,jdbcType=DATE}, 
      #{endDate,jdbcType=DATE}, #{preheatDate,jdbcType=DATE}, #{preheatImg,jdbcType=VARCHAR}, 
      #{startDate,jdbcType=DATE}, #{status,jdbcType=VARCHAR}, #{thumbMinUrl,jdbcType=VARCHAR}, 
      #{thumbUrl,jdbcType=VARCHAR}, #{userCount,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, 
      #{videoTime,jdbcType=VARCHAR}, #{videoUrl,jdbcType=VARCHAR}, #{contentDetail,jdbcType=LONGVARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.cab.model.CabLiveContent" useGeneratedKeys="true" keyProperty="contentId">
    insert into cab_live_content
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="contentId != null" >
        content_id,
      </if>
      <if test="contentTitle != null" >
        content_title,
      </if>
      <if test="createDate != null" >
        create_Date,
      </if>
      <if test="endDate != null" >
        end_date,
      </if>
      <if test="preheatDate != null" >
        preheat_date,
      </if>
      <if test="preheatImg != null" >
        preheat_img,
      </if>
      <if test="startDate != null" >
        start_date,
      </if>
      <if test="status != null" >
        status,
      </if>
      <if test="thumbMinUrl != null" >
        thumb_min_url,
      </if>
      <if test="thumbUrl != null" >
        thumb_url,
      </if>
      <if test="userCount != null" >
        user_count,
      </if>
      <if test="userId != null" >
        user_id,
      </if>
      <if test="videoTime != null" >
        video_time,
      </if>
      <if test="videoUrl != null" >
        video_url,
      </if>
      <if test="contentDetail != null" >
        content_detail,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="contentId != null" >
        #{contentId,jdbcType=INTEGER},
      </if>
      <if test="contentTitle != null" >
        #{contentTitle,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null" >
        #{createDate,jdbcType=DATE},
      </if>
      <if test="endDate != null" >
        #{endDate,jdbcType=DATE},
      </if>
      <if test="preheatDate != null" >
        #{preheatDate,jdbcType=DATE},
      </if>
      <if test="preheatImg != null" >
        #{preheatImg,jdbcType=VARCHAR},
      </if>
      <if test="startDate != null" >
        #{startDate,jdbcType=DATE},
      </if>
      <if test="status != null" >
        #{status,jdbcType=VARCHAR},
      </if>
      <if test="thumbMinUrl != null" >
        #{thumbMinUrl,jdbcType=VARCHAR},
      </if>
      <if test="thumbUrl != null" >
        #{thumbUrl,jdbcType=VARCHAR},
      </if>
      <if test="userCount != null" >
        #{userCount,jdbcType=INTEGER},
      </if>
      <if test="userId != null" >
        #{userId,jdbcType=INTEGER},
      </if>
      <if test="videoTime != null" >
        #{videoTime,jdbcType=VARCHAR},
      </if>
      <if test="videoUrl != null" >
        #{videoUrl,jdbcType=VARCHAR},
      </if>
      <if test="contentDetail != null" >
        #{contentDetail,jdbcType=LONGVARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.cab.model.CabLiveContent" >
    update cab_live_content
    <set >
      <if test="contentTitle != null" >
        content_title = #{contentTitle,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null" >
        create_Date = #{createDate,jdbcType=DATE},
      </if>
      <if test="endDate != null" >
        end_date = #{endDate,jdbcType=DATE},
      </if>
      <if test="preheatDate != null" >
        preheat_date = #{preheatDate,jdbcType=DATE},
      </if>
      <if test="preheatImg != null" >
        preheat_img = #{preheatImg,jdbcType=VARCHAR},
      </if>
      <if test="startDate != null" >
        start_date = #{startDate,jdbcType=DATE},
      </if>
      <if test="status != null" >
        status = #{status,jdbcType=VARCHAR},
      </if>
      <if test="thumbMinUrl != null" >
        thumb_min_url = #{thumbMinUrl,jdbcType=VARCHAR},
      </if>
      <if test="thumbUrl != null" >
        thumb_url = #{thumbUrl,jdbcType=VARCHAR},
      </if>
      <if test="userCount != null" >
        user_count = #{userCount,jdbcType=INTEGER},
      </if>
      <if test="userId != null" >
        user_id = #{userId,jdbcType=INTEGER},
      </if>
      <if test="videoTime != null" >
        video_time = #{videoTime,jdbcType=VARCHAR},
      </if>
      <if test="videoUrl != null" >
        video_url = #{videoUrl,jdbcType=VARCHAR},
      </if>
      <if test="contentDetail != null" >
        content_detail = #{contentDetail,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where content_id = #{contentId,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.cab.model.CabLiveContent" >
    update cab_live_content
    set content_title = #{contentTitle,jdbcType=VARCHAR},
      create_Date = #{createDate,jdbcType=DATE},
      end_date = #{endDate,jdbcType=DATE},
      preheat_date = #{preheatDate,jdbcType=DATE},
      preheat_img = #{preheatImg,jdbcType=VARCHAR},
      start_date = #{startDate,jdbcType=DATE},
      status = #{status,jdbcType=VARCHAR},
      thumb_min_url = #{thumbMinUrl,jdbcType=VARCHAR},
      thumb_url = #{thumbUrl,jdbcType=VARCHAR},
      user_count = #{userCount,jdbcType=INTEGER},
      user_id = #{userId,jdbcType=INTEGER},
      video_time = #{videoTime,jdbcType=VARCHAR},
      video_url = #{videoUrl,jdbcType=VARCHAR},
      content_detail = #{contentDetail,jdbcType=LONGVARCHAR}
    where content_id = #{contentId,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.cab.model.CabLiveContent" >
    update cab_live_content
    set content_title = #{contentTitle,jdbcType=VARCHAR},
      create_Date = #{createDate,jdbcType=DATE},
      end_date = #{endDate,jdbcType=DATE},
      preheat_date = #{preheatDate,jdbcType=DATE},
      preheat_img = #{preheatImg,jdbcType=VARCHAR},
      start_date = #{startDate,jdbcType=DATE},
      status = #{status,jdbcType=VARCHAR},
      thumb_min_url = #{thumbMinUrl,jdbcType=VARCHAR},
      thumb_url = #{thumbUrl,jdbcType=VARCHAR},
      user_count = #{userCount,jdbcType=INTEGER},
      user_id = #{userId,jdbcType=INTEGER},
      video_time = #{videoTime,jdbcType=VARCHAR},
      video_url = #{videoUrl,jdbcType=VARCHAR}
    where content_id = #{contentId,jdbcType=INTEGER}
  </update>
  <select id="selectAll" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Integer" >
    select
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from cab_live_content
    where 1=1
    <if test="title != '' and  title != null" >
      and content_title = #{title,jdbcType=INTEGER}
    </if>
    order by create_Date DESC
    limit #{start},#{limit}
  </select>
  <select id="selectCount" resultType="java.lang.Long" parameterType="java.lang.Integer" >
    select count(*)
    from cab_live_content
    where 1=1
    <if test="title != '' and  title != null" >
      and content_title = #{title,jdbcType=INTEGER}
    </if>
  </select>
</mapper>