118 lines
3.7 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="DubFavorite">
<select id="findFavoriteByDubIdAndType" parameterType="java.util.Map" resultType="DubFavorite">
SELECT uid, dubid, type, created
FROM dubfavorite
WHERE uid = #{uid} AND dubid = #{dubid} AND type = #{type}
</select>
<select id="findFavoriteByPK" parameterType="java.util.Map" resultType="DubFavorite">
SELECT uid, dubid, type, created
FROM dubfavorite
WHERE uid = #{uid} AND dubid = #{dubid} AND type = #{type}
</select>
<insert id="doSaveFavorite" parameterType="DubFavorite">
INSERT INTO DubFavorite(uid,dubid,type,created)
VALUES (#{uid},#{dubid},#{type},#{created})
</insert>
<delete id="doDeleteFavorite" parameterType="DubFavorite">
DELETE FROM dubfavorite
WHERE uid = #{uid} AND dubid = #{dubid} AND type = #{type}
</delete>
<select id="findMyFavorites" parameterType="java.util.Map" resultType="DubFavorite">
SELECT uid, dubid, type, created
FROM dubfavorite
WHERE uid = #{uid}
ORDER BY created DESC
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id="findMyFavoritesCount" parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT count(*)
FROM dubfavorite
WHERE uid = #{uid}
</select>
<select id="searchMyFavorites" parameterType="java.util.Map" resultType="ResDubInfo">
with temp as (
SELECT 0 AS voiceid,s.videoid,s.videoname,s.video AS videoURL,'' AS soundURL,
s.videopic,f.created,f.type AS dubType,s.assigntime,s.isteach,s.timelength,s.sentCount
FROM dubVideoStatic s
INNER JOIN (
SELECT uid, dubid, type, created
FROM dubFavorite
WHERE uid = #{uid}
AND type = '2'
) f
ON f.dubid = s.videoid
WHERE s.videoname LIKE #{keyWord}
UNION
SELECT u.voiceid,0 AS videoid,u.voicename AS videoname,'' AS videoURL,u.production AS soundURL,
v.videopic,f.created,f.type AS dubType
FROM dubUserVoice u
INNER JOIN dubVideoStatic v
ON v.videoid = u.videoid
INNER JOIN (
SELECT uid, dubid, type, created
FROM dubFavorite
WHERE uid = #{uid}
AND type = '1'
) f
ON f.dubid = u.voiceid
WHERE u.voicename LIKE #{keyWord})
select * from temp
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id="searchMyFavoritesCount" parameterType="java.util.Map" resultType="java.lang.Integer">
with temp as (
SELECT 0 AS voiceid,s.videoid,s.videoname,s.video AS videoURL,'' AS soundURL,
s.videopic,f.created,f.type AS dubType
FROM dubVideoStatic s
INNER JOIN (
SELECT uid, dubid, type, created
FROM dubFavorite
WHERE uid = #{uid}
AND type = '2'
) f
ON f.dubid = s.videoid
WHERE s.videoname LIKE #{keyWord}
UNION
SELECT u.voiceid,0 AS videoid,u.voicename AS videoname,'' AS videoURL,u.production AS soundURL,
v.videopic,f.created,f.type AS dubType
FROM dubUserVoice u
INNER JOIN dubVideoStatic v
ON v.videoid = u.videoid
INNER JOIN (
SELECT uid, dubid, type, created
FROM dubFavorite
WHERE uid = #{uid}
AND type = '1'
) f
ON f.dubid = u.voiceid
WHERE u.voicename LIKE #{keyWord})
select count(*) from temp
</select>
</mapper>