add 转移历史记录
This commit is contained in:
@ -7,7 +7,7 @@ from app.db.models.downloadhistory import DownloadHistory
|
||||
|
||||
class DownloadHistoryOper(DbOper):
|
||||
"""
|
||||
插件数据管理
|
||||
下载历史管理
|
||||
"""
|
||||
|
||||
def get_by_path(self, path: Path) -> Any:
|
||||
|
33
app/db/models/transferhistory.py
Normal file
33
app/db/models/transferhistory.py
Normal file
@ -0,0 +1,33 @@
|
||||
import time
|
||||
|
||||
from sqlalchemy import Column, Integer, String, Sequence
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.db.models import Base
|
||||
|
||||
|
||||
class TransferHistory(Base):
|
||||
"""
|
||||
转移历史记录
|
||||
"""
|
||||
id = Column(Integer, Sequence('id'), primary_key=True, index=True)
|
||||
src = Column(String, index=True)
|
||||
dest = Column(String)
|
||||
mode = Column(String)
|
||||
type = Column(String)
|
||||
category = Column(String)
|
||||
title = Column(String, index=True)
|
||||
year = Column(String)
|
||||
tmdbid = Column(Integer)
|
||||
imdbid = Column(String)
|
||||
tvdbid = Column(Integer)
|
||||
doubanid = Column(String)
|
||||
seasons = Column(Integer)
|
||||
episodes = Column(String)
|
||||
image = Column(String)
|
||||
download_hash = Column(String)
|
||||
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()
|
24
app/db/transferhistory_oper.py
Normal file
24
app/db/transferhistory_oper.py
Normal file
@ -0,0 +1,24 @@
|
||||
from typing import Any
|
||||
|
||||
from app.db import DbOper
|
||||
from app.db.models.transferhistory import TransferHistory
|
||||
|
||||
|
||||
class TransferHistoryOper(DbOper):
|
||||
"""
|
||||
转移历史管理
|
||||
"""
|
||||
|
||||
def get_by_title(self, title: str) -> Any:
|
||||
"""
|
||||
按标题查询转移记录
|
||||
:param title: 数据key
|
||||
"""
|
||||
return TransferHistory.search_by_title(self._db, title)
|
||||
|
||||
def add(self, **kwargs):
|
||||
"""
|
||||
新增转移历史
|
||||
"""
|
||||
transferhistory = TransferHistory(**kwargs)
|
||||
return transferhistory.create(self._db)
|
Reference in New Issue
Block a user