add 历史记录API
This commit is contained in:
@ -30,3 +30,9 @@ class DownloadHistoryOper(DbOper):
|
||||
"""
|
||||
downloadhistory = DownloadHistory(**kwargs)
|
||||
return downloadhistory.create(self._db)
|
||||
|
||||
def list_by_page(self, page: int = 1, count: int = 30):
|
||||
"""
|
||||
分页查询下载历史
|
||||
"""
|
||||
return DownloadHistory.list_by_page(self._db, page, count)
|
||||
|
@ -29,3 +29,7 @@ class DownloadHistory(Base):
|
||||
@staticmethod
|
||||
def get_by_hash(db: Session, download_hash: str):
|
||||
return db.query(DownloadHistory).filter(DownloadHistory.download_hash == download_hash).first()
|
||||
|
||||
@staticmethod
|
||||
def list_by_page(db: Session, page: int = 1, count: int = 30):
|
||||
return db.query(DownloadHistory).offset((page - 1) * count).limit(count).all()
|
||||
|
@ -29,5 +29,10 @@ class TransferHistory(Base):
|
||||
date = Column(String, index=True, default=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
|
||||
|
||||
@staticmethod
|
||||
def search_by_title(db: Session, title: str):
|
||||
return db.query(TransferHistory).filter(TransferHistory.title == title).all()
|
||||
def list_by_title(db: Session, title: str, page: int = 1, count: int = 30):
|
||||
return db.query(TransferHistory).filter(TransferHistory.title == title).offset((page - 1) * count).limit(
|
||||
count).all()
|
||||
|
||||
@staticmethod
|
||||
def list_by_page(db: Session, page: int = 1, count: int = 30):
|
||||
return db.query(TransferHistory).offset((page - 1) * count).limit(count).all()
|
||||
|
Reference in New Issue
Block a user