Skip to content

Commit 6e4d0aa

Browse files
authored
Merge pull request #104 from BUAA-SE-coders007/fix/103
[fix]: 修复组织文献不可阅读
2 parents 834631b + 3f89699 commit 6e4d0aa

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

app/curd/article.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ async def crud_read_article(user_id: int, article_id: int, db: AsyncSession):
103103
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)
104104
result = await db.execute(query)
105105
relation = result.first()
106-
if not relation[4]:
106+
if relation and not relation[4]:
107107
raise HTTPException(status_code=405, detail="You have no access to the article")
108108
# 进行阅读
109109
article.clicks = article.clicks + 1
@@ -127,7 +127,7 @@ async def crud_read_article_by_url(user_id: int, article_id: int, db: AsyncSessi
127127
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)
128128
result = await db.execute(query)
129129
relation = result.first()
130-
if not relation[4]:
130+
if relation and not relation[4]:
131131
raise HTTPException(status_code=405, detail="You have no access to the article")
132132
# 进行阅读
133133
article.clicks = article.clicks + 1

0 commit comments

Comments
 (0)