From 2c7b0e9afe602edcf0d1913d7af3aef84f92f10b Mon Sep 17 00:00:00 2001 From: martsforever Date: Thu, 16 Oct 2025 14:42:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20general=EF=BC=9Alist=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E6=94=AF=E6=8C=81withCount=E5=8F=82=E6=95=B0=EF=BC=8C=E5=B8=A6?= =?UTF-8?q?=E4=B8=8A=E8=BF=99=E4=B8=AA=E5=8F=82=E6=95=B0=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=E5=88=86=E9=A1=B5=E6=9F=A5=E8=AF=A2=E6=97=B6=E4=B8=80?= =?UTF-8?q?=E5=B9=B6=E8=BF=94=E5=9B=9E=E6=80=BB=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/general/general_utils/sql_service.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/general/general_utils/sql_service.py b/app/general/general_utils/sql_service.py index 07bf810..1b056bd 100644 --- a/app/general/general_utils/sql_service.py +++ b/app/general/general_utils/sql_service.py @@ -43,6 +43,7 @@ async def list(session: AsyncSessionDep, query_config, module_config, debug_data n_page = get_value(query_config, 'page', 0) n_size = get_value(query_config, 'size', 5) n_only_count = get_value(query_config, 'onlyCount', False) + n_with_count = get_value(query_config, 'withCount', False) offset = n_page * n_size # 多查一条数据,方便判断是否有下一页数据 @@ -77,8 +78,17 @@ async def list(session: AsyncSessionDep, query_config, module_config, debug_data has_next = False if get_value(query_config, 'all', False) else len(result) == n_size + 1 if has_next: result.pop() + + count_result = await list( + session, + query_config={**query_config, "onlyCount": True}, + module_config=module_config, + debug_data=debug_data, + user=user + ) if n_with_count else {} return { "hasNext": has_next, + **count_result, "list": result, } except Exception as err: