484 lines
19 KiB
XML
484 lines
19 KiB
XML
<?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="DubUserVoice">
|
||
|
||
|
||
<select id="findNewProduction" parameterType="java.util.Map" resultType="ResDubInfo">
|
||
SELECT a.videopic, t.voicename AS videoName, t.uid AS copyrighter, a.source, t.videoid as videoID, t.voiceid as voiceID, t.playcount as playCount,
|
||
t.likecount as likeCount,
|
||
t.production AS soundURL, t.created,a.timelength,a.sentcount,a.isteach,a.assigntime
|
||
FROM dubuservoice t
|
||
INNER JOIN dubvideostatic a
|
||
ON t.videoid = a.videoid
|
||
|
||
WHERE t.isdelete = 0
|
||
AND t.isshare = 1
|
||
AND t.draft = 'OK'
|
||
<if test="voicename != null">
|
||
AND t.voicename like '%'||#{voicename}||'%'
|
||
</if>
|
||
ORDER BY t.created DESC
|
||
<if test="page != null">
|
||
LIMIT #{page.limit} OFFSET #{page.offset}
|
||
</if>
|
||
</select>
|
||
|
||
<select id="findNewProductionCount" parameterType="java.util.Map" resultType="java.lang.Integer">
|
||
SELECT count(*)
|
||
FROM dubuservoice t
|
||
INNER JOIN dubvideostatic a
|
||
ON t.videoid = a.videoid
|
||
|
||
WHERE t.isdelete = 0
|
||
AND t.isshare = 1
|
||
AND t.draft = 'OK'
|
||
<if test="voicename != null">
|
||
AND t.voicename like '%'||#{voicename}||'%'
|
||
</if>
|
||
</select>
|
||
|
||
|
||
|
||
|
||
|
||
<select id="findHotProductionforHomePage" parameterType="java.util.Map" resultType="DubVideo">
|
||
SELECT b.videoid as videoID, videoname as videoName, video, sound, soundeffect as soundEffect, subtitle, description,
|
||
uploader, created, interpreter, reviser, difficulty, source,
|
||
copyrighter, crowd, type, label, videopic as videoPic, keyword as keyWord, status, playcount as playCount, dubcount as dubCount, priority,
|
||
a.starttime, a.summary,a.timelength,a.sentcount,a.isteach,a.assigntime
|
||
FROM dubvideostatic a
|
||
LEFT JOIN dubvideodynamic b ON a.videoid = b.videoid
|
||
where a.starttime < current_timestamp
|
||
AND status = 1
|
||
ORDER BY playcount DESC, date_trunc('day',a.starttime) DESC, priority DESC, dubcount DESC, difficulty DESC
|
||
<if test="page != null">
|
||
LIMIT #{page.limit} OFFSET #{page.offset}
|
||
</if>
|
||
</select>
|
||
|
||
|
||
<select id="findteachProductionforHomePage" parameterType="java.util.Map" resultType="DubVideo">
|
||
SELECT b.videoid, videoname, video, sound, soundeffect, subtitle, description,timeLength,sentCount,
|
||
uploader, created, interpreter, reviser, difficulty, source,
|
||
copyrighter, crowd, type, label, videopic, keyword, status, playcount, dubcount, priority,
|
||
a.starttime, a.summary,a.timelength,a.sentcount,a.isteach,a.assigntime
|
||
FROM dubvideostatic a
|
||
LEFT JOIN dubvideodynamic b ON a.videoid = b.videoid
|
||
where a.starttime < current_timestamp
|
||
AND status = 1 and a.isteach = 1
|
||
ORDER BY playcount DESC, date_trunc('day',a.starttime) DESC, priority DESC, dubcount DESC, difficulty DESC
|
||
<if test="page != null">
|
||
LIMIT #{page.limit} OFFSET #{page.offset}
|
||
</if>
|
||
|
||
</select>
|
||
|
||
|
||
|
||
<select id="findHotProductionforHomePageCount" resultType="java.lang.Integer">
|
||
SELECT count(*)
|
||
FROM dubvideostatic a
|
||
LEFT JOIN dubvideodynamic b ON a.videoid = b.videoid
|
||
where a.starttime < current_timestamp
|
||
AND status = 1
|
||
</select>
|
||
|
||
|
||
<select id="findByType" parameterType="java.util.Map" resultType="DubVideo">
|
||
SELECT b.videoid as videoID, videoname as videoName, video, sound, soundeffect as soundEffect, subtitle, description,
|
||
uploader, created, interpreter, reviser, difficulty, source,
|
||
copyrighter, crowd, type, label, videopic as videoPic, keyword as keyWord, status, playcount as playCount, dubcount as dubCount, priority,
|
||
a.starttime, a.summary,a.timelength,a.sentcount,a.isteach,a.assigntime
|
||
FROM dubvideostatic a
|
||
LEFT JOIN dubvideodynamic b ON a.videoid = b.videoid
|
||
<where>
|
||
<choose>
|
||
<when test="type == 'TEST'">
|
||
status <![CDATA[<>]]> 1
|
||
</when>
|
||
<when test="type == 'UNSTART'">
|
||
a.starttime > current_timestamp
|
||
AND status = 1
|
||
</when>
|
||
<otherwise>
|
||
a.starttime < current_timestamp
|
||
AND type = #{type} AND status = 1
|
||
</otherwise>
|
||
</choose>
|
||
</where>
|
||
ORDER BY date_trunc('day',a.starttime) DESC, priority DESC, playcount DESC, dubcount DESC, difficulty DESC
|
||
<if test="page != null">
|
||
LIMIT #{page.limit} OFFSET #{page.offset}
|
||
</if>
|
||
</select>
|
||
|
||
|
||
<select id="findByTypeCount" parameterType="java.util.Map" resultType="java.lang.Integer">
|
||
SELECT count(*)
|
||
FROM dubvideostatic a
|
||
LEFT JOIN dubvideodynamic b ON a.videoid = b.videoid
|
||
<where>
|
||
<choose>
|
||
<when test="type == 'TEST'">
|
||
status <![CDATA[<>]]> 1
|
||
</when>
|
||
<when test="type == 'UNSTART'">
|
||
a.starttime > current_timestamp
|
||
AND status = 1
|
||
</when>
|
||
<otherwise>
|
||
a.starttime < current_timestamp
|
||
AND type = #{type} AND status = 1
|
||
</otherwise>
|
||
</choose>
|
||
</where>
|
||
</select>
|
||
|
||
|
||
<select id="findVoiceRankListByVideo" parameterType="java.util.Map" resultType="ResDubRank">
|
||
SELECT voiceid as voiceID, likecount as likeCount, uid, voicename as voiceName, production ,created
|
||
FROM dubuservoice
|
||
WHERE videoid = #{videoid} AND isdelete = 0
|
||
AND isshare = 1 AND likecount > 0
|
||
ORDER BY likecount DESC, created ASC
|
||
<if test="page != null">
|
||
LIMIT #{page.limit} OFFSET #{page.offset}
|
||
</if>
|
||
</select>
|
||
|
||
|
||
<!-- 排行榜查询说明:
|
||
除全网外 schoolType 不为null
|
||
1、同班级:objType == 1
|
||
2、同年级:objType == 2
|
||
1、同校级:objType == 3
|
||
4、全网:objType 不传-->
|
||
<select id="findVoiceRankList" parameterType="java.util.Map" resultType="ResDubRank">
|
||
WITH temp1 AS (
|
||
SELECT a.videoid, a.uid, a.voiceid , a.likecount,a.rank2, a.production,a.voicename,a.created,
|
||
row_number() OVER(PARTITION BY a.videoid ORDER BY a.likecount DESC) AS rank1
|
||
FROM(
|
||
SELECT u.videoid, u.uid, u.voiceid , u.likecount, u.production,u.voicename,u.created,
|
||
row_number() OVER(PARTITION BY u.uid ORDER BY u.likecount DESC) AS rank2
|
||
FROM DubUserVoice u
|
||
<if test="schoolType != null">
|
||
RIGHT JOIN
|
||
<if test="schoolType == 'UNIV'.toString()">
|
||
univstudentownclass s
|
||
</if>
|
||
<if test="schoolType != 'UNIV'.toString()">
|
||
studentownclass s
|
||
</if>
|
||
ON s.studentid = u.uid and s.status=1
|
||
RIGHT JOIN
|
||
<if test="schoolType == 'UNIV'.toString()">
|
||
univclasses c
|
||
</if>
|
||
<if test="schoolType != 'UNIV'.toString()">
|
||
classes c
|
||
</if>
|
||
ON c.classesid = s.classesid and c.status=1
|
||
</if>
|
||
<choose>
|
||
<when test="reqFiltrate.day == 1">
|
||
WHERE u.created > (current_timestamp + interval'-1 day')
|
||
</when>
|
||
<when test="reqFiltrate.week == 1">
|
||
WHERE u.created > (current_date + interval'-1 week')
|
||
AND u.created < current_date
|
||
</when>
|
||
<otherwise>
|
||
WHERE u.created > (current_date + interval'-1 month')
|
||
AND u.created < current_date
|
||
</otherwise>
|
||
</choose>
|
||
AND u.isdelete = 0 AND isshare = 1
|
||
AND u.likecount > 0
|
||
<if test="objType == 1">
|
||
AND s.classesid = #{classesId} AND c.classtype = 1
|
||
</if>
|
||
<if test="objType == 2">
|
||
AND c.classlevel = #{classlevel}
|
||
AND c.schoolyear = #{schoolyear}
|
||
AND c.schoolid = #{schoolid}
|
||
AND c.classtype = 1
|
||
</if>
|
||
<if test="objType == 3">
|
||
AND c.schoolid = #{schoolid}
|
||
AND c.classtype = 1
|
||
</if>
|
||
) a
|
||
WHERE a.rank2 <=3
|
||
)
|
||
SELECT uid , voiceid as voiceID, likecount as likeCount, production, voicename as voiceName
|
||
FROM temp1
|
||
WHERE rank1 <=3
|
||
ORDER BY likecount DESC, created ASC
|
||
<if test="page != null">
|
||
LIMIT #{page.limit} OFFSET #{page.offset}
|
||
</if>
|
||
</select>
|
||
|
||
<select id="findVoiceRankListCount" parameterType="java.util.Map" resultType="java.lang.Integer">
|
||
WITH temp1 AS (
|
||
SELECT a.videoid, a.uid, a.voiceid , a.likecount,a.rank2, a.production,a.voicename,a.created,
|
||
row_number() OVER(PARTITION BY a.videoid ORDER BY a.likecount DESC) AS rank1
|
||
FROM(
|
||
SELECT u.videoid, u.uid, u.voiceid , u.likecount, u.production,u.voicename,u.created,
|
||
row_number() OVER(PARTITION BY u.uid ORDER BY u.likecount DESC) AS rank2
|
||
FROM DubUserVoice u
|
||
<if test="schoolType != null">
|
||
RIGHT JOIN
|
||
<if test="schoolType == 'UNIV'.toString()">
|
||
univstudentownclass s
|
||
</if>
|
||
<if test="schoolType != 'UNIV'.toString()">
|
||
studentownclass s
|
||
</if>
|
||
ON s.studentid = u.uid and s.status=1
|
||
RIGHT JOIN
|
||
<if test="schoolType == 'UNIV'.toString()">
|
||
univclasses c
|
||
</if>
|
||
<if test="schoolType != 'UNIV'.toString()">
|
||
classes c
|
||
</if>
|
||
ON c.classesid = s.classesid and c.status=1
|
||
</if>
|
||
<choose>
|
||
<when test="reqFiltrate.day == 1">
|
||
WHERE u.created > (current_timestamp + interval'-1 day')
|
||
</when>
|
||
<when test="reqFiltrate.week == 1">
|
||
WHERE u.created > (current_date + interval'-1 week')
|
||
AND u.created < current_date
|
||
</when>
|
||
<otherwise>
|
||
WHERE u.created > (current_date + interval'-1 month')
|
||
AND u.created < current_date
|
||
</otherwise>
|
||
</choose>
|
||
AND u.isdelete = 0 AND isshare = 1
|
||
AND u.likecount > 0
|
||
<if test="objType == 1">
|
||
AND s.classesid = #{classesId} AND c.classtype = 1
|
||
</if>
|
||
<if test="objType == 2">
|
||
AND c.classlevel = #{classlevel}
|
||
AND c.schoolyear = #{schoolyear}
|
||
AND c.schoolid = #{schoolid}
|
||
AND c.classtype = 1
|
||
</if>
|
||
<if test="objType == 3">
|
||
AND c.schoolid = #{schoolid}
|
||
AND c.classtype = 1
|
||
</if>
|
||
) a
|
||
WHERE a.rank2 <=3
|
||
)
|
||
SELECT count(uid)
|
||
FROM temp1
|
||
WHERE rank1 <=3
|
||
|
||
</select>
|
||
|
||
|
||
<select id="getDubSupport" parameterType="java.util.Map" resultType="DubSupport">
|
||
select * from dubsupport where voiceid=#{voiceId} and uid = #{uid}
|
||
</select>
|
||
|
||
<select id="getSeqDubUserVoice" resultType="Integer" useCache="false" flushCache="true">
|
||
|
||
select nextval('seq_dubuservoice')
|
||
|
||
</select>
|
||
|
||
|
||
<insert id="doSaveUserVoice" parameterType="DubUserVoice">
|
||
INSERT INTO dubuservoice(voiceid,uid,videoid,voicename,isshare,playcount,isdelete,thirdpartylink,production,isrecommend,recommendtime,award,created,areaid,draft,likecount)
|
||
VALUES (
|
||
<if test="voiceId == 0">
|
||
(SELECT NEXTVAL('seq_dubuservoice')),
|
||
</if>
|
||
<if test="voiceId != 0">
|
||
#{voiceId},
|
||
</if>
|
||
#{uid},#{videoId},#{voiceName},#{isShare},#{playCount},#{isdelete},#{thirdPartyLink},#{production},#{isRecommend},#{recommendTime},#{award},#{created},#{areaId},#{draft},#{likeCount})
|
||
</insert>
|
||
|
||
|
||
<select id="findVoiceByID" parameterType="java.lang.Long" resultType="DubUserVoice">
|
||
SELECT b.voiceid as voiceId,b.uid,b.videoid as videoId, b.voicename as voiceName ,b.isshare as isShare, b.playcount as playCount, b.isdelete, b.thirdpartylink as thirdPartyLink, b.production, b.isrecommend as isRecommend,b.award,
|
||
b.created,b.areaid as areaId,b.recommendTime as recommendtime,b.draft,b.likecount as likeCount
|
||
FROM DubUserVoice as b
|
||
WHERE voiceId = #{voiceid}
|
||
</select>
|
||
|
||
<select id="getUserCount" parameterType="java.lang.Long" resultType="java.lang.Integer">
|
||
SELECT COUNT(DISTINCT(uid))
|
||
FROM dubuservoice
|
||
WHERE videoid = #{videoid} AND isdelete = 0 AND isshare = 1
|
||
</select>
|
||
|
||
<select id="findUserIdByVideoId" parameterType="java.lang.Long" resultType="DubUserVoice">
|
||
SELECT voiceid as voiceid,uid,production,voicename as voiceName
|
||
FROM dubuservoice
|
||
WHERE videoid = #{videoid} AND isdelete = 0 AND isshare = 1
|
||
ORDER BY created DESC LIMIT 20
|
||
</select>
|
||
|
||
<select id="findDubByIDUserVoice" parameterType="java.lang.Long" resultType="DubUserVoice">
|
||
SELECT voiceid as voiceId ,uid,videoid as videoId,voicename as voiceName ,isshare as isShare,
|
||
playcount as playCount,isdelete,thirdpartylink as thirdPartyLink,production,
|
||
isrecommend as isRecommend,recommendtime as recommendTime,award,created,
|
||
areaid as areaId ,draft,likecount as likeCount
|
||
FROM DubUserVoice
|
||
WHERE voiceid = #{voiceid} AND isdelete = 0
|
||
</select>
|
||
|
||
<update id="doUpdateUserVoicById" parameterType="java.util.Map">
|
||
Update dubuservoice
|
||
<set>
|
||
<if test="uid != null">uid = #{uid},</if>
|
||
<if test="videoid != null">videoid = #{videoid},</if>
|
||
<if test="voicename != null">voicename = #{voicename},</if>
|
||
<if test="isshare != null">isshare = #{isshare},</if>
|
||
<if test="playcount != null">playcount = ${playcount},</if>
|
||
<if test="isdelete != null">isdelete = #{isdelete},</if>
|
||
<if test="thirdpartylink != null">thirdpartylink = #{thirdpartylink},</if>
|
||
<if test="production != null">production = #{production},</if>
|
||
<if test="isrecommend != null">isrecommend = #{isrecommend},</if>
|
||
<if test="recommendtime != null">recommendtime = #{recommendtime},</if>
|
||
<if test="award != null">award = #{award},</if>
|
||
<if test="created != null">created = #{created},</if>
|
||
<if test="areaid != null">areaid = #{areaid},</if>
|
||
<if test="draft != null">draft = #{draft},</if>
|
||
<if test="likecount != null">likecount = ${likecount}</if>
|
||
</set>
|
||
WHERE voiceid = #{voiceid}
|
||
</update>
|
||
|
||
|
||
<select id="getDubsCount" parameterType="java.util.Map" resultType="java.lang.Integer">
|
||
SELECT count(voiceid)
|
||
FROM dubuservoice
|
||
WHERE uid = #{uid} AND isdelete = 0
|
||
<choose>
|
||
<when test="type == 'A'.toString()">
|
||
AND isshare = 1 AND draft = 'OK'
|
||
</when>
|
||
<when test="type == 'B'.toString()">
|
||
AND isshare = 0 AND draft = 'OK'
|
||
</when>
|
||
<when test="type == 'C'.toString()">
|
||
AND isshare = 0 draft != 'OK'
|
||
</when>
|
||
<otherwise>
|
||
AND 1 = -1
|
||
</otherwise>
|
||
</choose>
|
||
</select>
|
||
|
||
<select id="findDubsByUser" parameterType="java.util.Map" resultType="DubUserVoice">
|
||
SELECT voiceid as voiceId, videoid as videoId, voicename as voiceName, created, production, award,playcount as playCount,likecount
|
||
as likeCount
|
||
FROM dubuservoice
|
||
WHERE uid = #{uid} AND isdelete = 0
|
||
<if test="otherOrMe == 'OTHER'.toString()">
|
||
<if test="type == 'A'.toString()">
|
||
AND isshare = 1 AND draft = 'OK'
|
||
</if>
|
||
<if test="type != 'A'.toString()">
|
||
AND 1 = -1
|
||
</if>
|
||
</if>
|
||
<if test="otherOrMe != 'OTHER'.toString()">
|
||
<choose>
|
||
<when test="type == 'A'.toString()">
|
||
AND isshare = 1 AND draft = 'OK'
|
||
</when>
|
||
<when test="type == 'B'.toString()">
|
||
AND isshare = 0 AND draft = 'OK'
|
||
</when>
|
||
<when test="type == 'C'.toString()">
|
||
AND isshare = 0 draft != 'OK'
|
||
</when>
|
||
<otherwise>
|
||
AND 1 = -1
|
||
</otherwise>
|
||
</choose>
|
||
</if>
|
||
ORDER BY created DESC
|
||
<if test="page != null">
|
||
LIMIT #{page.limit} OFFSET #{page.offset}
|
||
</if>
|
||
</select>
|
||
|
||
|
||
<select id="findDubsByUserCount" parameterType="java.util.Map" resultType="java.lang.Integer">
|
||
SELECT count(*)
|
||
FROM dubuservoice
|
||
WHERE uid = #{uid} AND isdelete = 0
|
||
<if test="otherOrMe == 'OTHER'.toString()">
|
||
<if test="type == 'A'.toString()">
|
||
AND isshare = 1 AND draft = 'OK'
|
||
</if>
|
||
<if test="type != 'A'.toString()">
|
||
AND 1 = -1
|
||
</if>
|
||
</if>
|
||
<if test="otherOrMe != 'OTHER'.toString()">
|
||
<choose>
|
||
<when test="type == 'A'.toString()">
|
||
AND isshare = 1 AND draft = 'OK'
|
||
</when>
|
||
<when test="type == 'B'.toString()">
|
||
AND isshare = 0 AND draft = 'OK'
|
||
</when>
|
||
<when test="type == 'C'.toString()">
|
||
AND isshare = 0 draft != 'OK'
|
||
</when>
|
||
<otherwise>
|
||
AND 1 = -1
|
||
</otherwise>
|
||
</choose>
|
||
</if>
|
||
</select>
|
||
|
||
|
||
<select id="searchDubsByUser" parameterType="java.util.Map" resultType="DubUserVoice">
|
||
SELECT voiceid as voiceId, videoid as videoId, voicename as voiceName, created, production, award,playcount as playCount,likecount as likeCount
|
||
FROM dubuservoice
|
||
WHERE uid = #{uid} AND isdelete = 0
|
||
<if test="voicename != null">
|
||
AND voicename like '%'||#{voicename}||'%'
|
||
</if>
|
||
AND isshare = 1 AND draft = 'OK'
|
||
ORDER BY created DESC
|
||
<if test="page != null">
|
||
LIMIT #{page.limit} OFFSET #{page.offset}
|
||
</if>
|
||
</select>
|
||
|
||
<select id="searchDubsByUserCount" parameterType="java.util.Map" resultType="java.lang.Integer">
|
||
SELECT count(*)
|
||
FROM dubuservoice
|
||
WHERE uid = #{uid} AND isdelete = 0
|
||
<if test="voicename != null">
|
||
AND voicename like '%'||#{voicename}||'%'
|
||
</if>
|
||
AND isshare = 1 AND draft = 'OK'
|
||
|
||
|
||
</select>
|
||
|
||
|
||
<select id="findDubVoiceNum" parameterType="java.util.Map" resultType="java.lang.Integer">
|
||
select count(*) from dubuservoice d
|
||
inner join studentownclass st on d.uid = st.studentid and st.status = 1
|
||
and st.areaid = #{areaId} and st.classesid =#{classesId} and d.isdelete = 0 and
|
||
d.created between #{startTime} and #{endTime}
|
||
</select>
|
||
|
||
</mapper> |