package com.example.system.mapper;

import com.example.system.model.CommentTable;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.List;

@Mapper
public interface CommentMapper {
    //删除对应文章的所有评论
    @Delete("DELETE FROM comment_table WHERE article_id = #{id};")
    Integer deleteCommentByArticleId(Integer id);

    //根据文章id获取所有的评论
    @Select("select * from comment_table where article_id=#{id}")
    List<CommentTable> getCommentById(Integer id);

    //根据评论id获取对应的评论
    @Select("select * from comment_table where comment_id=#{id}")
    CommentTable getById(Long id);

    //根据评论id删除评论
    @Delete("DELETE from comment_table where comment_id=#{id};")
    int deleteById(Long id);
}
