<?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.chinacreator.video.restful.dao.NewYearVideoDao" >



    <insert id="insertVideoInfo">

	  INSERT INTO TD_WXVIDEO_QUEUE a (ID,USERID,BASE64CODE,videomodules,seqnumber,modulesname,modulestime)
		    VALUES (#{id},#{wxuserid},#{photos},#{modules},seq_newyearvideo.nextval,#{modulesname},#{modulestime})

    </insert>

    <select id="queryVideoInfo" resultType="java.util.Map">
    select ID, USERID,videourl,to_char(FINISHTIME,'yyyy-MM-dd hh24:mi:ss')FINISHTIME ,MODULESNAME from TD_WXVIDEO_QUEUE
    where userid=#{wxuserid}  and status = '4' order by seqnumber desc
    </select>

    <select id="getID" resultType="string">
    select TO_CHAR(SYSDATE,'yyyyMMddhh24miss')||SEQ_COMMON6.nextval　from dual
    </select>

	<select id="queryNumber" resultType="int">
		select row_number from (select row_number() over(order by seqnumber) as row_number,t.* from TD_WXVIDEO_QUEUE t where status = '-1' )
		where id = #{id}
    </select>

    <select id="queryNumber2" resultType="int">
        select row_number from (select * from (select row_number() over(order by seqnumber) as row_number,
        t.* from TD_WXVIDEO_QUEUE t where status = '-1') where userid =#{wxuserid}  order by inserttime desc)  <![CDATA[where rownum< 2]]>
    </select>

    <select id="queryUserStatus" resultType="string">
        select status from (select STATUS from TD_WXVIDEO_QUEUE where userid =#{wxuserid} order by seqnumber desc) <![CDATA[where rownum< 2]]>
    </select>

    <update id="hasRset" >
		update TD_WXVIDEO_QUEUE SET status = '5'  where userid = #{wxuserid}
    </update>

    <update id="hasFinished" >
		update TD_WXVIDEO_QUEUE SET status = #{state} , finishtime = sysdate , returnvideourl=#{video_url}  where id = #{wid}
    </update>
</mapper>