diff --git a/app/api/v1/endpoints/articleDB.py b/app/api/v1/endpoints/articleDB.py index 715ddbd..b82d127 100644 --- a/app/api/v1/endpoints/articleDB.py +++ b/app/api/v1/endpoints/articleDB.py @@ -131,7 +131,6 @@ async def copy_article(folder_id: int, article_id: int, is_group: bool | None = raise HTTPException(status_code=500, detail=str(e)) return {"msg": "Article copied successfully", "new_article_id": new_article_id} - @router.get("/recommend", response_model=dict) async def recommend_article(recommend_article: RecommendArticle = Depends(), db: AsyncSession = Depends(get_db)): articles = await recommend_article_in_db(db=db, recommend_article=recommend_article) diff --git a/app/curd/articleDB.py b/app/curd/articleDB.py index 1670657..b034b8d 100644 --- a/app/curd/articleDB.py +++ b/app/curd/articleDB.py @@ -77,6 +77,8 @@ async def get_article_info_in_db_by_id(db: AsyncSession, article_id: int): """ result = await db.execute(select(ArticleDB).where(ArticleDB.id == article_id)) article = result.scalars().first() + if not article: + return None, None return article.file_path, article.title async def recommend_article_in_db(db: AsyncSession, recommend_article: RecommendArticle):