package com.ruoyi.post.frequency.postcomment.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.controller.req.DialoguePageReq;
import com.ruoyi.controller.resp.CommentNum;
import com.ruoyi.post.controller.req.PostCommentPageReq;
import com.ruoyi.post.controller.resp.PostCommentPageResp;
import com.ruoyi.post.controller.resp.PostCommentResp;
import com.ruoyi.post.frequency.postcomment.entity.PostComment;
import com.ruoyi.vo.UserVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 帖子评论Mapper接口
 *
 * @author liwenlong
 * @date 2023-10-09
 */
public interface PostCommentMapper  extends BaseMapper<PostComment>
{
    /**
     * 查询帖子评论
     *
     * @param id 帖子评论主键
     * @return 帖子评论
     */
    public PostComment selectPostCommentById(Long id);

    /**
     * 查询帖子评论列表
     *
     * @param postComment 帖子评论
     * @return 帖子评论集合
     */
    public List<PostComment> selectPostCommentList(PostComment postComment);

    /**
     * 新增帖子评论
     *
     * @param postComment 帖子评论
     * @return 结果
     */
    public int insertPostComment(PostComment postComment);

    /**
     * 修改帖子评论
     *
     * @param postComment 帖子评论
     * @return 结果
     */
    public int updatePostComment(PostComment postComment);

    /**
     * 修改帖子评论
     *
     * @param postComment 帖子评论
     * @return 结果
     */
    public int updatePostCommentNumBatch(@Param("list") List<PostComment> postComment);


    /**
     * 删除帖子评论
     *
     * @param id 帖子评论主键
     * @return 结果
     */
    public int deletePostCommentById(Long id);

    /**
     * 批量删除帖子评论
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deletePostCommentByIds(Long[] ids);


    /**
     *获取评论后数据
     * @param id
     * @return
     */
    PostCommentResp getPostCommentResp(@Param("id")Long id,@Param("userVo") UserVo userVo);


    /**
     * 帖子评论列表
     * @param objectPage
     * @param req
     * @param userVo
     * @return
     */
    Page<PostCommentPageResp> postCommentPage(@Param("page")Page<Object> objectPage, @Param("req") PostCommentPageReq req, @Param("userVo") UserVo userVo);

    List<CommentNum> selectCommentNumList(@Param("commentIds") List<Long> commentIds,@Param("userVoList") List<UserVo> userVoList);

    List<PostComment> selectedNewCommentList(@Param("postIds") List<Long> postIds);

    @Update("update t_post_comment set like_num = like_num + #{num} , update_time=now() where id = #{id}")
    int updatePostCommentLikeNum(@Param("id") Long id, @Param("num") Integer num);

    List<PostCommentPageResp> postCommentList(@Param("req") PostCommentPageReq req,@Param("userVo") UserVo userVo,@Param("list") List<Long> parentIds);

    Page<PostCommentPageResp> postCommentDialoguePage(@Param("page") Page<Object> objectPage,@Param("req") DialoguePageReq req,@Param("userVo") UserVo userVo);
}
