fix 历史记录翻页
This commit is contained in:
parent
579d7f0574
commit
bd729feb66
@ -40,22 +40,25 @@ def delete_download_history(history_in: schemas.DownloadHistory,
|
||||
def transfer_history(title: str = None,
|
||||
page: int = 1,
|
||||
count: int = 30,
|
||||
sort: dict = None,
|
||||
db: Session = Depends(get_db),
|
||||
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
||||
"""
|
||||
查询转移历史记录
|
||||
"""
|
||||
if title:
|
||||
return schemas.Response(success=True,
|
||||
data={
|
||||
"list": TransferHistory.list_by_title(db, title, page, count),
|
||||
"total": TransferHistory.count_by_title(db, title),
|
||||
})
|
||||
total = TransferHistory.count_by_title(db, title)
|
||||
result = TransferHistory.list_by_title(db, title, page, count)
|
||||
else:
|
||||
result = TransferHistory.list_by_page(db, page, count)
|
||||
total = TransferHistory.count(db)
|
||||
# 排序
|
||||
if sort:
|
||||
pass
|
||||
return schemas.Response(success=True,
|
||||
data={
|
||||
"list": TransferHistory.list_by_page(db, page, count),
|
||||
"total": TransferHistory.count(db),
|
||||
"list": result,
|
||||
"total": total,
|
||||
})
|
||||
|
||||
|
||||
|
@ -46,7 +46,7 @@ class TransferHistory(Base):
|
||||
|
||||
@staticmethod
|
||||
def list_by_title(db: Session, title: str, page: int = 1, count: int = 30):
|
||||
return db.query(TransferHistory).filter(TransferHistory.title == title).order_by(
|
||||
return db.query(TransferHistory).filter(TransferHistory.title.like(f'%{title}%')).order_by(
|
||||
TransferHistory.date.desc()).offset((page - 1) * count).limit(
|
||||
count).all()
|
||||
|
||||
@ -76,4 +76,4 @@ class TransferHistory(Base):
|
||||
|
||||
@staticmethod
|
||||
def count_by_title(db: Session, title: str):
|
||||
return db.query(func.count(TransferHistory.id)).filter(TransferHistory.title == title).first()[0]
|
||||
return db.query(func.count(TransferHistory.id)).filter(TransferHistory.title.like(f'%{title}%')).first()[0]
|
||||
|
Loading…
x
Reference in New Issue
Block a user