package com.example.system.mapper;

import com.example.system.model.ArticleTable;
import org.apache.ibatis.annotations.*;

import javax.persistence.criteria.CriteriaBuilder;
import java.util.List;

@Mapper
public interface ArticleMapper {

    //获取历史文章记录并按照升序排列
    @Select("select * from article_table order by publish_time asc;")
    List<ArticleTable> getHistoryArticle();

    //发布文章
    Integer createArticle(ArticleTable article);

    //根据文章id来获取对应的文章
    @Select("select * from article_table where article_id=#{id};")
    ArticleTable getArticleById(Integer id);

    //根据文章id来删除对应的文章
    @Delete("DELETE FROM article_table WHERE article_id = #{id};")
    Integer deleteArticleById(Integer userId);

    //更新对应的文章信息
    @Update("UPDATE article_table SET " +
            "article_title = #{articleTitle}, brief_content = #{briefContent}, " +
            "article_content = #{articleContent}, article_type = #{articleType} , publish_time=#{publishTime}" +
            "WHERE article_id = #{articleId}")
    Integer updataArtical(ArticleTable articleTable);
}
