diff --git a/app/model/article.py b/app/model/article.py index a3b4bf7..15dfef2 100644 --- a/app/model/article.py +++ b/app/model/article.py @@ -32,3 +32,16 @@ def get_page_articles(num, size): x for x in Article.select().order_by(desc(Article.article_id)).page(num, size) ] + + +def get_article_by_id(article_id): + article_id &= 0xFFFFFFFF # max 32 bits + with db_session: + article = Article.select(article_id=article_id).first() + if article: + return article.to_dict() + + +def get_all_articles(): + with db_session: + return [art.to_dict() for art in Article.select()[:]] \ No newline at end of file