package top.lejings.demo.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import top.lejings.demo.pojo.Comments;
import org.apache.ibatis.annotations.Delete;
import java.util.List;

@Mapper
public interface CommentsMapper {

    List<Comments> getComment(Integer postId);

    void addComment(Comments comments);

    // 根据用户名搜索评论

    List<Comments> searchByUser(@Param("username") String username);

    // 根据内容搜索评论

    List<Comments> searchByContent(@Param("content") String content);

    @Delete("DELETE FROM comments WHERE comment_id = #{comment_id} AND post_id = #{post_id} AND user_id = #{user_id}")
    void delete(Comments comments);
}
