From 3f89699ebf9813ef2a2d74eea100e367321cc34a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A9=E6=98=95=E7=9D=BF?= <22371298@buaa.edu.cn> Date: Sat, 7 Jun 2025 21:03:41 +0800 Subject: [PATCH] =?UTF-8?q?[fix]:=20=E4=BF=AE=E5=A4=8D=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E6=96=87=E7=8C=AE=E4=B8=8D=E5=8F=AF=E9=98=85=E8=AF=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/curd/article.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/curd/article.py b/app/curd/article.py index d3bb78f..0d6dc59 100644 --- a/app/curd/article.py +++ b/app/curd/article.py @@ -103,7 +103,7 @@ async def crud_read_article(user_id: int, article_id: int, db: AsyncSession): query = select(operate_permissions).where(operate_permissions.c.user_id == user_id, operate_permissions.c.item_type == 2, operate_permissions.c.item_id == article_id) result = await db.execute(query) relation = result.first() - if not relation[4]: + if relation and not relation[4]: raise HTTPException(status_code=405, detail="You have no access to the article") # 进行阅读 article.clicks = article.clicks + 1 @@ -127,7 +127,7 @@ async def crud_read_article_by_url(user_id: int, article_id: int, db: AsyncSessi query = select(operate_permissions).where(operate_permissions.c.user_id == user_id, operate_permissions.c.item_type == 2, operate_permissions.c.item_id == article_id) result = await db.execute(query) relation = result.first() - if not relation[4]: + if relation and not relation[4]: raise HTTPException(status_code=405, detail="You have no access to the article") # 进行阅读 article.clicks = article.clicks + 1