187 lines
7.1 KiB
XML
Raw Normal View History

2026-03-10 14:30:24 +08:00
<?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="DubVideo">
<select id="findByKeyWord" parameterType="java.util.Map" resultType="DubVideo">
SELECT b.videoid, video, videoname, description,
created, difficulty, source,
copyrighter, crowd, label, videopic, playcount,a.assigntime,a.timelength,a.sentcount
FROM dubvideostatic a
LEFT JOIN dubvideodynamic b ON a.videoid = b.videoid
<where>
<if test ="keyWord != null and keyWord != ''">
and (lower(videoname) like lower(#{keyWord}) or lower(description) like lower(#{keyWord})or lower(source) like
lower(#{keyWord}))
</if>
<choose>
<when test="type == 'TEST'">
and status <![CDATA[<>]]> 1
</when>
<when test="type == 'UNSTART'">
and a.starttime &gt; current_timestamp
AND status = 1
</when>
<otherwise>
and a.starttime &lt; current_timestamp
<if test="type != null and type != ''.toString()">
AND type = #{type}
</if>
AND status = 1
</otherwise>
</choose>
</where>
ORDER BY (length(videoname)-length(#{keyWord})) ASC
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id="findByKeyWordCount" parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT count(*)
FROM dubvideostatic a
LEFT JOIN dubvideodynamic b ON a.videoid = b.videoid
<where>
<if test ="keyWord != null and keyWord != ''">
and (lower(videoname) like lower(#{keyWord}) or lower(description) like lower(#{keyWord})or lower(source) like
lower(#{keyWord}))
</if>
<choose>
<when test="type == 'TEST'">
and status <![CDATA[<>]]> 1
</when>
<when test="type == 'UNSTART'">
and a.starttime &gt; current_timestamp
AND status = 1
</when>
<otherwise>
and a.starttime &lt; current_timestamp
<if test="type != null and type != ''.toString()">
AND type = #{type}
</if>
AND status = 1
</otherwise>
</choose>
</where>
</select>
<select id="findByKeyWord_Hot" parameterType="java.util.Map" resultType="ResDubInfo">
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,a.assigntime,a.timelength,a.sentcount
FROM dubvideostatic a
LEFT JOIN dubvideodynamic b ON a.videoid = b.videoid
ORDER BY b.playcount desc
LIMIT 100
)
SELECT * from temp
WHERE starttime &lt; now()
AND status = 1
<if test="keyWord != null and keyWord != ''">
and (lower(videoname) like lower(#{keyWord}) or lower(description) like lower(#{keyWord})or lower(source) like lower(#{keyWord}))
</if>
ORDER BY (length(videoname)-length(#{keyWord})) ASC
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id="findByKeyWord_HotCount" parameterType="java.util.Map" resultType="java.lang.Integer">
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,a.assigntime
FROM dubvideostatic a
LEFT JOIN dubvideodynamic b ON a.videoid = b.videoid
ORDER BY b.playcount desc
LIMIT 100
)
SELECT count(*) from temp
WHERE starttime &lt; now()
AND status = 1
<if test="keyWord != null and keyWord != ''">
and (lower(videoname) like lower(#{keyWord}) or lower(description) like lower(#{keyWord})or lower(source) like lower(#{keyWord}))
</if>
</select>
<select id="findByKeyWord_EveryDay" parameterType="java.util.Map" resultType="ResDubInfo">
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,a.assigntime,a.timelength,a.sentcount
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>
<if test="keyWord != null and keyWord != ''">
and lower(videoName) like lower(#{keyWord})
</if>
</where>
ORDER BY likeCount DESC,created DESC
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id="findByKeyWord_EveryDayCount" parameterType="java.util.Map" resultType="java.lang.Integer">
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 count(*) from temp
<where>
<if test="keyWord != null and keyWord != ''">
and lower(videoName) like lower(#{keyWord})
</if>
</where>
</select>
<select id="findDubStaticByID" parameterType="java.lang.Long" resultType="DubVideoStaticDecorater">
SELECT ds.*,dd.playcount
FROM dubvideostatic ds LEFT JOIN dubvideodynamic dd on ds.videoid=dd.videoid
WHERE ds.videoid = #{videoid}
</select>
<select id="findDubByID" parameterType="java.lang.Long" resultType="DubVideo">
SELECT b.videoid, videoname, video, sound, soundeffect, subtitle, description,
uploader, created, interpreter, reviser, difficulty, source,
copyrighter, crowd, type, label, videopic, keyword, status, playcount, dubcount, priority,
a.starttime, a.summary,a.assigntime,a.isteach,a.timelength,a.sentCount
FROM dubvideostatic a
LEFT JOIN dubvideodynamic b ON a.videoid = b.videoid
WHERE b.videoid = #{videoid}
</select>
<update id="doUpdateVideoDynamicById" parameterType="java.util.Map">
Update dubvideodynamic
<set>
<if test="playcount != null">playcount = ${playcount},</if>
<if test="dubcount != null">dubcount = ${dubcount}</if>
</set>
WHERE videoid = #{videoid}
</update>
</mapper>