390 lines
14 KiB
XML
390 lines
14 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="com._3e.dubdao.DubVideoDao">
|
|
<select id="findDubStaticByID" parameterType="long" resultType="com.dub.entity.DubVideoStatic">
|
|
SELECT ds.*,dd.playcount
|
|
FROM dubvideostatic ds LEFT JOIN dubvideodynamic dd on ds.videoid=dd.videoid
|
|
WHERE ds.videoid = #{videoid}
|
|
</select>
|
|
|
|
<update id="doUpdateVideoDynamicById" parameterType="map">
|
|
Update dubvideodynamic
|
|
<set>
|
|
<if test="playcount != null">playcount = ${playcount},</if>
|
|
<if test="dubcount != null">dubcount = ${dubcount}</if>
|
|
</set>
|
|
WHERE videoid = #{videoid}
|
|
</update>
|
|
|
|
<select id="findDubByID" parameterType="long" resultType="com.dub.dto.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,s.knowledge
|
|
FROM dubvideostatic a
|
|
left join (select t3.videoid,string_agg(p.valuestr, ',') knowledge from dubvideotag t3
|
|
inner join parameter p on t3.tagid = p.paraid
|
|
where p.paratype = 35 and p.paraint = 3 GROUP BY t3.videoid) s on a.videoid = s.videoid
|
|
LEFT JOIN dubvideodynamic b ON a.videoid = b.videoid
|
|
WHERE b.videoid = #{videoid}
|
|
</select>
|
|
|
|
<select id="findByType" parameterType="map" resultType="com.dub.dto.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
|
|
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 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="findByKeyWord" parameterType="map" resultType="com.dub.dto.DubVideo">
|
|
SELECT b.videoid, video, videoname, description,
|
|
created, difficulty, source,
|
|
copyrighter, crowd, label, videopic, playcount
|
|
FROM dubvideostatic a
|
|
LEFT JOIN dubvideodynamic b ON a.videoid = b.videoid
|
|
WHERE lower(keyWord) like lower(#{keyWord})
|
|
<if test="type != null and type != ''">
|
|
AND a.type = #{type}
|
|
</if>
|
|
AND a.starttime < current_timestamp
|
|
AND status = 1
|
|
ORDER BY (length(keyWord)-length(#{keyWord})) ASC
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
<select id="findByKeyWord_1" parameterType="map" resultType="com.dub.dto.DubVideo">
|
|
SELECT b.videoid, video, videoname, description,
|
|
created, difficulty, source,
|
|
copyrighter, crowd, label, videopic, playcount
|
|
FROM dubvideostatic a
|
|
LEFT JOIN dubvideodynamic b ON a.videoid = b.videoid
|
|
WHERE (lower(videoname) like lower(#{keyWord}) or lower(description) like lower(#{keyWord})or lower(source) like lower(#{keyWord}))
|
|
<choose>
|
|
<when test="type == 'TEST'">
|
|
and status <![CDATA[<>]]> 1
|
|
</when>
|
|
<when test="type == 'UNSTART'">
|
|
and a.starttime > current_timestamp
|
|
AND status = 1
|
|
</when>
|
|
<otherwise>
|
|
and a.starttime < current_timestamp
|
|
<if test="type != null and type != ''.toString()">
|
|
AND type = #{type}
|
|
</if>
|
|
AND status = 1
|
|
</otherwise>
|
|
</choose>
|
|
ORDER BY (length(videoname)-length(#{keyWord})) ASC
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
<select id="findByKeyWord_Hot" parameterType="map" resultType="com.dub.dto.ResDubInfo_1">
|
|
with temp as(
|
|
SELECT b.videoid, a.video, a.videoname, a.description,a.starttime,a.status,
|
|
a.created, a.difficulty, a.source,
|
|
a.copyrighter, a.crowd, a.label, a.videopic, b.playcount
|
|
FROM dubvideostatic a
|
|
LEFT JOIN dubvideodynamic b ON a.videoid = b.videoid
|
|
ORDER BY b.playcount desc
|
|
LIMIT 100
|
|
)
|
|
SELECT * from temp
|
|
WHERE (lower(videoname) like lower(#{keyWord}) or lower(description) like lower(#{keyWord})or lower(source) like lower(#{keyWord}))
|
|
and starttime < now()
|
|
AND status = 1
|
|
|
|
ORDER BY (length(videoname)-length(#{keyWord})) ASC
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="findByKeyWord_EveryDay" parameterType="map" resultType="com.dub.dto.ResDubInfo_1">
|
|
WITH temp as (SELECT a.videopic, t.voicename AS videoName, t.uid AS copyrighter, a.source, t.videoid, t.voiceid, t.playcount, t.likeCount,
|
|
t.production AS soundURL, t.created
|
|
FROM dubuservoice t
|
|
INNER JOIN dubvideostatic a
|
|
ON t.videoid = a.videoid
|
|
|
|
WHERE t.isdelete = 0
|
|
AND t.isshare = 1
|
|
AND t.draft = 'OK'
|
|
LIMIT 100)
|
|
|
|
SELECT * from temp where
|
|
|
|
videoName like '%'||#{keyWord}||'%'
|
|
|
|
ORDER BY likeCount DESC,created DESC
|
|
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
<select id="findDubDifficulty" resultType="com.dub.dto.ResDubDifficulty">
|
|
select difficulty from dubVideoStatic group by difficulty order by difficulty
|
|
</select>
|
|
<select id="findDubStaticByPlate" resultType="com.dub.dto.ResDubInfo">
|
|
SELECT b.videoid, videoname, video, sound, soundeffect, subtitle, description,
|
|
uploader, a.created, interpreter, reviser, difficulty, source,
|
|
copyrighter, crowd, type, label, videopic, keyword, a.status, playcount, dubcount, priority,
|
|
a.starttime, a.summary,a.timeLength,a.sentCount
|
|
FROM dubvideostatic a
|
|
LEFT JOIN dubvideodynamic b ON a.videoid = b.videoid
|
|
<if test="gradeType != null">
|
|
inner join dubvideotag t1 on t1.videoid = a.videoid and t1.tagid = #{gradeType} and t1.status =1
|
|
</if>
|
|
<if test="themeType != null ">
|
|
inner join dubvideotag t2 on t2.videoid = a.videoid and t2.tagid = #{themeType} and t2.status =1
|
|
</if>
|
|
<if test="knowledgeType != null ">
|
|
inner join dubvideotag t3 on t3.videoid = a.videoid and t3.tagid = #{knowledgeType} and t3.status =1
|
|
</if>
|
|
<where>
|
|
<if test="isTeach != null">
|
|
and a.isTeach = #{isTeach}
|
|
</if>
|
|
<if test="difficultyType != null">
|
|
and a.difficulty = #{difficultyType}
|
|
</if>
|
|
<if test="timeLengthType != null">
|
|
<choose>
|
|
<when test="timeLengthType == 1">
|
|
and a.timeLength >= 0 and a.timeLength <= 60
|
|
</when>
|
|
<when test="timeLengthType == 2">
|
|
and a.timeLength > 60 and a.timeLength <= 120
|
|
</when>
|
|
<when test="timeLengthType == 3">
|
|
and a.timeLength > 120 and a.timeLength <= 180
|
|
</when>
|
|
<when test="timeLengthType == 4">
|
|
and a.timeLength > 180 and a.timeLength <= 300
|
|
</when>
|
|
<when test="timeLengthType == 5">
|
|
and a.timeLength > 300
|
|
</when>
|
|
</choose>
|
|
</if>
|
|
<if test="sentenceNumType != null">
|
|
<choose>
|
|
<when test="sentenceNumType == 1">
|
|
and a.sentCount >= 1 and a.sentCount <= 2
|
|
</when>
|
|
<when test="sentenceNumType == 2">
|
|
and a.sentCount >= 3 and a.sentCount <= 5
|
|
</when>
|
|
<when test="sentenceNumType == 3">
|
|
and a.sentCount >= 6 and a.sentCount <= 9
|
|
</when>
|
|
<when test="sentenceNumType == 4">
|
|
and a.sentCount >= 10
|
|
</when>
|
|
</choose>
|
|
</if>
|
|
<if test="bigType != null">
|
|
<choose>
|
|
<when test="bigType == 'TEST'">
|
|
and a.status <![CDATA[<>]]> 1
|
|
</when>
|
|
<when test="bigType == 'UNSTART'">
|
|
and a.starttime > current_timestamp
|
|
AND a.status = 1
|
|
</when>
|
|
<otherwise>
|
|
and a.starttime < current_timestamp
|
|
AND a.status = 1
|
|
and a.type = #{bigType}
|
|
</otherwise>
|
|
</choose>
|
|
</if>
|
|
<if test="bigType == null">
|
|
and a.starttime < current_timestamp
|
|
AND a.status = 1
|
|
</if>
|
|
order by a.starttime desc,a.created desc
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
<select id="findHotDubStaticByPlate" resultType="com.dub.dto.ResDubInfo">
|
|
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.assignTime
|
|
FROM dubvideostatic a
|
|
LEFT JOIN dubvideodynamic b ON a.videoid = b.videoid
|
|
where
|
|
a.starttime < current_timestamp
|
|
AND status = 1
|
|
<if test="keyWord != null">
|
|
and (lower(videoname) like lower(#{keyWord}) or lower(description) like lower(#{keyWord})or lower(source) like lower(#{keyWord}))
|
|
</if>
|
|
<if test="difficultyType != null">
|
|
and a.difficulty = #{difficultyType}
|
|
</if>
|
|
<if test="timeLengthType != null">
|
|
<choose>
|
|
<when test="timeLengthType == 1">
|
|
and a.timeLength >= 0 and a.timeLength <= 60
|
|
</when>
|
|
<when test="timeLengthType == 2">
|
|
and a.timeLength > 60 and a.timeLength <= 120
|
|
</when>
|
|
<when test="timeLengthType == 3">
|
|
and a.timeLength > 120 and a.timeLength <= 180
|
|
</when>
|
|
<when test="timeLengthType == 4">
|
|
and a.timeLength > 180 and a.timeLength <= 300
|
|
</when>
|
|
<when test="timeLengthType == 5">
|
|
and a.timeLength > 300
|
|
</when>
|
|
</choose>
|
|
</if>
|
|
<if test="sentenceNumType != null">
|
|
<choose>
|
|
<when test="sentenceNumType == 1">
|
|
and a.sentCount >= 1 and a.sentCount <= 2
|
|
</when>
|
|
<when test="sentenceNumType == 2">
|
|
and a.sentCount >= 3 and a.sentCount <= 5
|
|
</when>
|
|
<when test="sentenceNumType == 3">
|
|
and a.sentCount >= 6 and a.sentCount <= 9
|
|
</when>
|
|
<when test="sentenceNumType == 4">
|
|
and a.sentCount >= 10
|
|
</when>
|
|
</choose>
|
|
</if>
|
|
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="findNewDubStaticByPlate" resultType="com.dub.dto.ResDubInfo">
|
|
SELECT a.videopic, t.voicename AS videoName, t.uid AS copyrighter, a.source, t.videoid, t.voiceid, t.playcount, t.likeCount,a.timeLength,a.sentCount,
|
|
t.production AS soundURL, t.created,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="keyWord != null">
|
|
and (lower(videoname) like lower(#{keyWord}) or lower(description) like lower(#{keyWord})or lower(source) like lower(#{keyWord}))
|
|
</if>
|
|
<if test="difficultyType != null">
|
|
and a.difficulty = #{difficultyType}
|
|
</if>
|
|
<if test="timeLengthType != null">
|
|
<choose>
|
|
<when test="timeLengthType == 1">
|
|
and a.timeLength >= 0 and a.timeLength <= 60
|
|
</when>
|
|
<when test="timeLengthType == 2">
|
|
and a.timeLength > 60 and a.timeLength <= 120
|
|
</when>
|
|
<when test="timeLengthType == 3">
|
|
and a.timeLength > 120 and a.timeLength <= 180
|
|
</when>
|
|
<when test="timeLengthType == 4">
|
|
and a.timeLength > 180 and a.timeLength <= 300
|
|
</when>
|
|
<when test="timeLengthType == 5">
|
|
and a.timeLength > 300
|
|
</when>
|
|
</choose>
|
|
</if>
|
|
<if test="sentenceNumType != null">
|
|
<choose>
|
|
<when test="sentenceNumType == 1">
|
|
and a.sentCount >= 1 and a.sentCount <= 2
|
|
</when>
|
|
<when test="sentenceNumType == 2">
|
|
and a.sentCount >= 3 and a.sentCount <= 5
|
|
</when>
|
|
<when test="sentenceNumType == 3">
|
|
and a.sentCount >= 6 and a.sentCount <= 9
|
|
</when>
|
|
<when test="sentenceNumType == 4">
|
|
and a.sentCount >= 10
|
|
</when>
|
|
</choose>
|
|
</if>
|
|
ORDER BY t.created DESC
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
<select id="findByKeyWordV3" resultType="com.dub.dto.DubVideo">
|
|
SELECT b.videoid, video, videoname, description,
|
|
created, difficulty, source,
|
|
copyrighter, crowd, label, videopic, playcount,timeLength,sentCount,a.assignTime
|
|
FROM dubvideostatic a
|
|
LEFT JOIN dubvideodynamic b ON a.videoid = b.videoid
|
|
WHERE (lower(videoname) like lower(#{keyWord}) or lower(description) like lower(#{keyWord})or lower(source) like lower(#{keyWord}))
|
|
<choose>
|
|
<when test="type == 'TEST'">
|
|
and status <![CDATA[<>]]> 1
|
|
</when>
|
|
<when test="type == 'UNSTART'">
|
|
and a.starttime > current_timestamp
|
|
AND status = 1
|
|
</when>
|
|
<otherwise>
|
|
and a.starttime < current_timestamp
|
|
<if test="type != null and type != ''.toString()">
|
|
AND type = #{type}
|
|
</if>
|
|
AND status = 1
|
|
</otherwise>
|
|
</choose>
|
|
<if test="isTeach != null">
|
|
and a.isTeach = #{isTeach}
|
|
</if>
|
|
ORDER BY (length(videoname)-length(#{keyWord})) ASC
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
<select id="findAllDubStatic" resultType="com.dub.dto.ResDubInfoAssign">
|
|
select b.videoid, videoname, video,videopic,type,vs.timeLength,vs.sentCount,vs.assignTime,difficulty,a1.gradeAffiliationStr,a2.themeStr,a3.knowledgeStr
|
|
from dubvideostatic vs LEFT JOIN dubvideodynamic b ON vs.videoId = b.videoId
|
|
left JOIN (select videoid, string_agg(paraid::text, ',') AS gradeAffiliationStr from parameter p INNER JOIN dubvideotag t1 on p.paraid = t1.tagid where p.paraint = 1 and paratype =35 GROUP BY videoid) a1 on vs.videoid = a1.videoid
|
|
left JOIN (select videoid, string_agg(paraid::text, ',') AS themeStr from parameter p INNER JOIN dubvideotag t2 on p.paraid= t2.tagid where p.paraint = 2 and paratype =35 GROUP BY videoid) a2 on vs.videoid = a2.videoid
|
|
left JOIN (select videoid, string_agg(paraid::text, ',') AS knowledgeStr from parameter p INNER JOIN dubvideotag t3 on p.paraid= t3.tagid where p.paraint = 3 and paratype =35 GROUP BY videoid) a3 on vs.videoid = a3.videoid
|
|
where vs.starttime < current_timestamp AND vs.status = 1 AND vs.isTeach = 1
|
|
order by vs.starttime desc,vs.created desc
|
|
</select>
|
|
|
|
</mapper>
|