This commit is contained in:
jxxghp
2023-07-02 14:37:36 +08:00
parent d21296b724
commit 96c7a3fc92
2 changed files with 8 additions and 3 deletions

View File

@ -9,6 +9,8 @@ from app.core.config import settings
from app.core.security import verify_token
from app.db import get_db
from app.db.models.subscribe import Subscribe
from app.db.models.user import User
from app.db.userauth import get_current_active_user
from app.schemas.types import MediaType
router = APIRouter()
@ -56,7 +58,7 @@ async def subscribe_info_by_id(
async def create_subscribe(
*,
subscribe_in: schemas.Subscribe,
_: schemas.TokenPayload = Depends(verify_token)
current_user: User = Depends(get_current_active_user),
) -> Any:
"""
新增订阅
@ -77,6 +79,7 @@ async def create_subscribe(
tmdbid=subscribe_in.tmdbid,
season=subscribe_in.season,
doubanid=subscribe_in.doubanid,
username=current_user.name,
exist_ok=True)
return schemas.Response(success=True if result else False, message=result)

View File

@ -46,12 +46,14 @@ 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).offset((page - 1) * count).limit(
return db.query(TransferHistory).filter(TransferHistory.title == title).order_by(
TransferHistory.date.desc()).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()
return db.query(TransferHistory).order_by(TransferHistory.date.desc()).offset((page - 1) * count).limit(
count).all()
@staticmethod
def get_by_hash(db: Session, download_hash: str):