Commit 3aac36fc authored by 陈涛's avatar 陈涛

修改查询bug

parent 455b09ef
...@@ -245,12 +245,12 @@ async def query_bill( ...@@ -245,12 +245,12 @@ async def query_bill(
query = {"fund_id": fund_id, "user_id": user.id, "bill_type": {'$in': query}} query = {"fund_id": fund_id, "user_id": user.id, "bill_type": {'$in': query}}
if filter_time.start_time and filter_time.end_time: if filter_time.start_time and filter_time.end_time:
query.update({'record_time': filter_time.to_mongodb_query()}) query.update({'record_time': filter_time.to_mongodb_query()})
count = await bill_collect.count_documents(query)
skip = (page.page - 1) * page.page_size skip = (page.page - 1) * page.page_size
cursor = bill_collect.find(query) cursor = bill_collect.find(query)
cursor = cursor.skip(skip).sort([(sort_by.sort_field, sort_by.sort_direction)]).limit(page.page_size) cursor = cursor.skip(skip).sort([(sort_by.sort_field, sort_by.sort_direction)]).limit(page.page_size)
result = await cursor.to_list(length=None) result = await cursor.to_list(length=None)
response = PageResponse[Any](data=result, **page.dict(), total=len(result)) response = PageResponse[Any](data=result, **page.dict(), total=count)
return response return response
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment