package com.fs.course.mapper;

import java.util.List;
import com.fs.course.domain.FsUserVideoCommentLike;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 课堂评论点赞Mapper接口
 *
 * @author fs
 * @date 2024-05-15
 */
public interface FsUserVideoCommentLikeMapper
{
    /**
     * 查询课堂评论点赞
     *
     * @param id 课堂评论点赞主键
     * @return 课堂评论点赞
     */
    public FsUserVideoCommentLike selectFsUserVideoCommentLikeById(Long id);

    /**
     * 查询课堂评论点赞列表
     *
     * @param fsUserVideoCommentLike 课堂评论点赞
     * @return 课堂评论点赞集合
     */
    public List<FsUserVideoCommentLike> selectFsUserVideoCommentLikeList(FsUserVideoCommentLike fsUserVideoCommentLike);

    /**
     * 新增课堂评论点赞
     *
     * @param fsUserVideoCommentLike 课堂评论点赞
     * @return 结果
     */
    public int insertFsUserVideoCommentLike(FsUserVideoCommentLike fsUserVideoCommentLike);

    /**
     * 修改课堂评论点赞
     *
     * @param fsUserVideoCommentLike 课堂评论点赞
     * @return 结果
     */
    public int updateFsUserVideoCommentLike(FsUserVideoCommentLike fsUserVideoCommentLike);

    /**
     * 删除课堂评论点赞
     *
     * @param id 课堂评论点赞主键
     * @return 结果
     */
    public int deleteFsUserVideoCommentLikeById(Long id);

    /**
     * 批量删除课堂评论点赞
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteFsUserVideoCommentLikeByIds(Long[] ids);


    @Select("SELECT COUNT(1) FROM fs_user_video_comment_like WHERE comment_id = #{commentId} AND user_id = #{userId}")
    int checkCommentLike(@Param("commentId") String commentId, @Param("userId") Long userId);

    @Select("<script>" +
            "SELECT comment_id FROM fs_user_video_comment_like WHERE user_id = #{userId} AND comment_id IN " +
            "<foreach item='commentId' collection='commentIds' open='(' separator=',' close=')'>" +
            "#{commentId}" +
            "</foreach>" +
            "</script>")
    List<Long> checkCommentLikes(@Param("commentIds") List<Long> commentIds, @Param("userId") Long userId);

    @Delete("DELETE FROM fs_user_video_comment_like WHERE comment_id = #{commentId} AND user_id = #{userId}")
    void deleteCommentLike(@Param("commentId") String commentId, @Param("userId") Long userId);

    @Select("SELECT COUNT(1)\n" +
            "        FROM fs_user_video_comment_like\n" +
            "        WHERE comment_id = #{commentId} ")
    Integer getCommentLikeCount(@Param("commentId") String commentId);
}
