<?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.goafanti.common.dao.JtVideoMapper">
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.JtVideo">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Nov 02 16:14:39 CST 2018.
    -->
    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="url" jdbcType="VARCHAR" property="url" />
    <result column="type" jdbcType="INTEGER" property="type" />
    <result column="owner" jdbcType="VARCHAR" property="owner" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="status" jdbcType="INTEGER" property="status" />
    <result column="summary" jdbcType="VARCHAR" property="summary" />
    <result column="cover_url" jdbcType="VARCHAR" property="coverUrl" />
    <result column="release_time" jdbcType="TIMESTAMP" property="releaseTime" />
    <result column="transcoding" jdbcType="INTEGER" property="transcoding" />
    <result column="md5" jdbcType="VARCHAR" property="md5" />
    <result column="position" jdbcType="INTEGER" property="position" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Nov 02 16:14:39 CST 2018.
    -->
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Nov 02 16:14:39 CST 2018.
    -->
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Nov 02 16:14:39 CST 2018.
    -->
    id, name, url, type, owner, create_time, status, summary, cover_url, release_time, 
    transcoding, md5, position
  </sql>
  <select id="selectByExample" parameterType="com.goafanti.common.model.JtVideoExample" resultMap="BaseResultMap">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Nov 02 16:14:39 CST 2018.
    -->
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from jt_video
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Nov 02 16:14:39 CST 2018.
    -->
    select 
    <include refid="Base_Column_List" />
    from jt_video
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Nov 02 16:14:39 CST 2018.
    -->
    delete from jt_video
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="com.goafanti.common.model.JtVideoExample">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Nov 02 16:14:39 CST 2018.
    -->
    delete from jt_video
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.goafanti.common.model.JtVideo">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Nov 02 16:14:39 CST 2018.
    -->
    insert into jt_video (id, name, url, 
      type, owner, create_time, 
      status, summary, cover_url, 
      release_time, transcoding, md5, 
      position)
    values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, 
      #{type,jdbcType=INTEGER}, #{owner,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, 
      #{status,jdbcType=INTEGER}, #{summary,jdbcType=VARCHAR}, #{coverUrl,jdbcType=VARCHAR}, 
      #{releaseTime,jdbcType=TIMESTAMP}, #{transcoding,jdbcType=INTEGER}, #{md5,jdbcType=VARCHAR}, 
      #{position,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.goafanti.common.model.JtVideo">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Nov 02 16:14:39 CST 2018.
    -->
    insert into jt_video
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="name != null">
        name,
      </if>
      <if test="url != null">
        url,
      </if>
      <if test="type != null">
        type,
      </if>
      <if test="owner != null">
        owner,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="status != null">
        status,
      </if>
      <if test="summary != null">
        summary,
      </if>
      <if test="coverUrl != null">
        cover_url,
      </if>
      <if test="releaseTime != null">
        release_time,
      </if>
      <if test="transcoding != null">
        transcoding,
      </if>
      <if test="md5 != null">
        md5,
      </if>
      <if test="position != null">
        position,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="url != null">
        #{url,jdbcType=VARCHAR},
      </if>
      <if test="type != null">
        #{type,jdbcType=INTEGER},
      </if>
      <if test="owner != null">
        #{owner,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="status != null">
        #{status,jdbcType=INTEGER},
      </if>
      <if test="summary != null">
        #{summary,jdbcType=VARCHAR},
      </if>
      <if test="coverUrl != null">
        #{coverUrl,jdbcType=VARCHAR},
      </if>
      <if test="releaseTime != null">
        #{releaseTime,jdbcType=TIMESTAMP},
      </if>
      <if test="transcoding != null">
        #{transcoding,jdbcType=INTEGER},
      </if>
      <if test="md5 != null">
        #{md5,jdbcType=VARCHAR},
      </if>
      <if test="position != null">
        #{position,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.goafanti.common.model.JtVideoExample" resultType="java.lang.Integer">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Nov 02 16:14:39 CST 2018.
    -->
    select count(*) from jt_video
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Nov 02 16:14:39 CST 2018.
    -->
    update jt_video
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=VARCHAR},
      </if>
      <if test="record.name != null">
        name = #{record.name,jdbcType=VARCHAR},
      </if>
      <if test="record.url != null">
        url = #{record.url,jdbcType=VARCHAR},
      </if>
      <if test="record.type != null">
        type = #{record.type,jdbcType=INTEGER},
      </if>
      <if test="record.owner != null">
        owner = #{record.owner,jdbcType=VARCHAR},
      </if>
      <if test="record.createTime != null">
        create_time = #{record.createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.status != null">
        status = #{record.status,jdbcType=INTEGER},
      </if>
      <if test="record.summary != null">
        summary = #{record.summary,jdbcType=VARCHAR},
      </if>
      <if test="record.coverUrl != null">
        cover_url = #{record.coverUrl,jdbcType=VARCHAR},
      </if>
      <if test="record.releaseTime != null">
        release_time = #{record.releaseTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.transcoding != null">
        transcoding = #{record.transcoding,jdbcType=INTEGER},
      </if>
      <if test="record.md5 != null">
        md5 = #{record.md5,jdbcType=VARCHAR},
      </if>
      <if test="record.position != null">
        position = #{record.position,jdbcType=INTEGER},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Nov 02 16:14:39 CST 2018.
    -->
    update jt_video
    set id = #{record.id,jdbcType=VARCHAR},
      name = #{record.name,jdbcType=VARCHAR},
      url = #{record.url,jdbcType=VARCHAR},
      type = #{record.type,jdbcType=INTEGER},
      owner = #{record.owner,jdbcType=VARCHAR},
      create_time = #{record.createTime,jdbcType=TIMESTAMP},
      status = #{record.status,jdbcType=INTEGER},
      summary = #{record.summary,jdbcType=VARCHAR},
      cover_url = #{record.coverUrl,jdbcType=VARCHAR},
      release_time = #{record.releaseTime,jdbcType=TIMESTAMP},
      transcoding = #{record.transcoding,jdbcType=INTEGER},
      md5 = #{record.md5,jdbcType=VARCHAR},
      position = #{record.position,jdbcType=INTEGER}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.JtVideo">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Nov 02 16:14:39 CST 2018.
    -->
    update jt_video
    <set>
      <if test="name != null">
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="url != null">
        url = #{url,jdbcType=VARCHAR},
      </if>
      <if test="type != null">
        type = #{type,jdbcType=INTEGER},
      </if>
      <if test="owner != null">
        owner = #{owner,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="status != null">
        status = #{status,jdbcType=INTEGER},
      </if>
      <if test="summary != null">
        summary = #{summary,jdbcType=VARCHAR},
      </if>
      <if test="coverUrl != null">
        cover_url = #{coverUrl,jdbcType=VARCHAR},
      </if>
      <if test="releaseTime != null">
        release_time = #{releaseTime,jdbcType=TIMESTAMP},
      </if>
      <if test="transcoding != null">
        transcoding = #{transcoding,jdbcType=INTEGER},
      </if>
      <if test="md5 != null">
        md5 = #{md5,jdbcType=VARCHAR},
      </if>
      <if test="position != null">
        position = #{position,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.JtVideo">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Nov 02 16:14:39 CST 2018.
    -->
    update jt_video
    set name = #{name,jdbcType=VARCHAR},
      url = #{url,jdbcType=VARCHAR},
      type = #{type,jdbcType=INTEGER},
      owner = #{owner,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      status = #{status,jdbcType=INTEGER},
      summary = #{summary,jdbcType=VARCHAR},
      cover_url = #{coverUrl,jdbcType=VARCHAR},
      release_time = #{releaseTime,jdbcType=TIMESTAMP},
      transcoding = #{transcoding,jdbcType=INTEGER},
      md5 = #{md5,jdbcType=VARCHAR},
      position = #{position,jdbcType=INTEGER}
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <!-- 查看视频列表 -->
  <select id="getVideoListBySome" parameterType="java.util.Map" resultType="com.goafanti.admin.bo.AdminVideoBo">
  	select  
  	v.id, v.name, url, type, owner, v.create_time as createTime, v.status, summary, cover_url as coverUrl, 
  	release_time as releaseTime, transcoding, md5, v.position, a.name as ownerName  
  	from jt_video v
	left join admin a on v.owner = a.id
  	where 1=1
  	<if test='v.name != null and v.name != ""'>
  	<bind name="n" value="'%' + v.name + '%' " />
	and v.name like #{n,jdbcType=VARCHAR}
  	</if>
  	<if test="v.type != null">
	and type = #{v.type,jdbcType=INTEGER}
  	</if>
  	<if test="v.status != null">
	and v.status = #{v.status,jdbcType=INTEGER}
  	</if>
  	<if test="v.status == null">
	and v.status &lt; 3
  	</if>
  	<if test="v.transcoding != null">
	and v.transcoding = #{v.transcoding,jdbcType=INTEGER}
  	</if>
  	<if test="v.owner != null">
	and owner = #{v.owner,jdbcType=VARCHAR}
  	</if>
  	<if test="ob == 1">
	order by v.create_time desc
  	</if>
  	<if test="ob == 2">
	order by v.release_time desc
  	</if>
	<if test="page_sql!=null">
		${page_sql}
	</if>
   </select>
   <!-- 查看视频列表数量 -->
   <select id="getVideoCountBySome" parameterType="java.util.Map" resultType="java.lang.Integer">
   select  
  	count(*)
  	from jt_video v
	left join admin a on v.owner = a.id
  	where 1=1
  	<if test='v.name != null and v.name != ""'>
  	<bind name="n" value="'%' + v.name + '%' " />
	and v.name like #{n,jdbcType=VARCHAR}
  	</if>
  	<if test="v.type != null">
	and v.type = #{v.type,jdbcType=INTEGER}
  	</if>
  	<if test="v.status != null">
	and v.status = #{v.status,jdbcType=INTEGER}
  	</if>
  	<if test="v.status == null">
	and v.status &lt; 3
  	</if>
  	<if test="v.transcoding != null">
	and v.transcoding = #{v.transcoding,jdbcType=INTEGER}
  	</if>
  	<if test="v.owner != null">
	and v.owner = #{v.owner,jdbcType=VARCHAR}
  	</if>
	<if test="ob == 1">
	order by v.create_time desc
  	</if>
  	<if test="ob == 2">
	order by v.release_time desc
  	</if>
   </select>
   <!-- 查看单个信息 -->
   <select id="selectById" parameterType="com.goafanti.common.model.JtVideo" resultType="com.goafanti.admin.bo.AdminVideoBo">
    select 
    v.id, v.name, url, type, owner, v.create_time as createTime, v.status, summary, cover_url as coverUrl, 
    release_time as releaseTime, transcoding, md5, v.position, a.name as ownerName  
  	from jt_video v
	left join admin a on v.owner = a.id
    where  v.id = #{id,jdbcType=VARCHAR}
    <if test="status != null">
    	and v.status = #{status,jdbcType=INTEGER}
    </if>
  </select>
  <!-- 根据url 修改数据 -->
  <update id="updateByUrl" parameterType="com.goafanti.common.model.JtVideo">
  	update jt_video
    <set>
      <if test="name != null">
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="type != null">
        type = #{type,jdbcType=INTEGER},
      </if>
      <if test="owner != null">
        owner = #{owner,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        status = #{status,jdbcType=INTEGER},
      </if>
      <if test="summary != null">
        summary = #{summary,jdbcType=VARCHAR},
      </if>
      <if test="coverUrl != null">
        cover_url = #{coverUrl,jdbcType=VARCHAR},
      </if>
      <if test="transcoding != null">
        transcoding = #{transcoding,jdbcType=INTEGER},
      </if>
      <if test="md5 != null">
        md5 = #{md5,jdbcType=VARCHAR},
      </if>
    </set>
    where url = #{url,jdbcType=VARCHAR}
  </update>
  <!-- 查看首页视频 -->
  <select id="getIndexVideo" parameterType="java.lang.Integer" resultType="com.goafanti.admin.bo.AdminVideoBo">
  select 
    id, name, url, type, owner, create_time as createTime, status, summary, cover_url as coverUrl, 
    release_time as releaseTime, transcoding, md5, position
  	from jt_video
    where 
    transcoding = 2
    and status = 1
    and position = #{position,jdbcType=INTEGER}
    order by release_time desc
    limit 1
  </select>
  <!-- 检查重复名称 -->
  <select id="nameCheck" parameterType="java.lang.String" resultType="java.lang.Integer">
  	select count(*) from jt_video where status &lt; 3 and name = #{_parameter,jdbcType=VARCHAR}
  </select>
  
  <!-- 查看所有视频信息 -->
  <select id="getAllVideoExcludeId" parameterType="java.lang.String" resultMap="BaseResultMap">
  	select 
     <include refid="Base_Column_List" />
  	from jt_video
    where 
    transcoding = 2
    and status = 1
    and id &lt;&gt; #{_parameter,jdbcType=VARCHAR}
    order by release_time desc
  </select>
  
</mapper>