Files
HAOVP/video-comment/src/main/resources/mapper/CommentLikeMapper.xml
T

22 lines
882 B
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.nuaa.video.comment.mapper.CommentLikeMapper">
<!-- 检查用户是否已点赞 -->
<select id="checkUserLiked" resultType="long">
SELECT COUNT(1)
FROM comment_like
WHERE comment_id = #{commentId}
AND user_id = #{userId}
AND type = #{type}
</select>
<!-- 统计视频评论点赞数 -->
<select id="countVideoCommentLikes" resultType="int">
SELECT COUNT(1)
FROM comment_like cl
LEFT JOIN comment c ON cl.comment_id = c.id AND cl.type = 1
LEFT JOIN comment_reply cr ON cl.comment_id = cr.id AND cl.type = 2
WHERE (c.video_id = #{videoId} OR cr.video_id = #{videoId})
</select>
</mapper>