Skip to content

Commit 5de59f5

Browse files
committed
fix: terminology page query may return empty list
1 parent dc4a738 commit 5de59f5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

backend/apps/terminology/curd/terminology.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ def page_terminology(session: SessionDep, current_page: int = 1, page_size: int
5959
total_count = session.execute(count_stmt).scalar()
6060
total_pages = (total_count + page_size - 1) // page_size
6161

62+
if current_page > total_pages:
63+
current_page = 1
64+
65+
6266
# 步骤3:获取分页后的父节点ID
6367
paginated_parent_ids = (
6468
parent_ids_subquery
@@ -104,6 +108,9 @@ def page_terminology(session: SessionDep, current_page: int = 1, page_size: int
104108
total_count = session.execute(count_stmt).scalar()
105109
total_pages = (total_count + page_size - 1) // page_size
106110

111+
if current_page > total_pages:
112+
current_page = 1
113+
107114
paginated_parent_ids = (
108115
parent_ids_subquery
109116
.order_by(Terminology.create_time.desc())

0 commit comments

Comments
 (0)