From e430a3e88bdb54046f9f1533e1c978be54ddf635 Mon Sep 17 00:00:00 2001 From: thsrite Date: Mon, 22 Apr 2024 15:49:57 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix=20=E8=8E=B7=E5=8F=96=E6=8C=87=E5=AE=9At?= =?UTF-8?q?mdb=5Fid=E7=9A=84=E8=AE=A2=E9=98=85=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/db/subscribe_oper.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/db/subscribe_oper.py b/app/db/subscribe_oper.py index 2ac445cf..8525ed81 100644 --- a/app/db/subscribe_oper.py +++ b/app/db/subscribe_oper.py @@ -89,6 +89,12 @@ class SubscribeOper(DbOper): subscribe.update(self._db, payload) return subscribe + def get_by_tmdbid(self, tmdbid: int, season: int = None) -> List[Subscribe]: + """ + 获取指定tmdb_id的订阅 + """ + return Subscribe.get_by_tmdbid(self._db, tmdbid=tmdbid, season=season) + def list_by_type(self, mtype: str, days: int = 7) -> Subscribe: """ 获取指定类型的订阅 From e519fc484b94d1e60adae156430bece98107b187 Mon Sep 17 00:00:00 2001 From: thsrite Date: Mon, 22 Apr 2024 15:56:50 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix=20=E8=8E=B7=E5=8F=96=E6=8C=87=E5=AE=9A?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=9A=84=E8=AE=A2=E9=98=85=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/db/models/subscribe.py | 19 +++++++++++++++++++ app/db/subscribe_oper.py | 6 ++++++ 2 files changed, 25 insertions(+) diff --git a/app/db/models/subscribe.py b/app/db/models/subscribe.py index fa0b0ae6..f74cbc20 100644 --- a/app/db/models/subscribe.py +++ b/app/db/models/subscribe.py @@ -135,6 +135,25 @@ class Subscribe(Base): subscribe.delete(db, subscribe.id) return True + @staticmethod + @db_query + def list_by_username(db: Session, username: str, state: str = None, mtype: str = None): + if mtype: + if state: + result = db.query(Subscribe).filter(Subscribe.state == state, + Subscribe.username == username, + Subscribe.type == mtype).all() + else: + result = db.query(Subscribe).filter(Subscribe.username == username, + Subscribe.type == mtype).all() + else: + if state: + result = db.query(Subscribe).filter(Subscribe.state == state, + Subscribe.username == username).all() + else: + result = db.query(Subscribe).filter(Subscribe.username == username).all() + return list(result) + @staticmethod @db_query def list_by_type(db: Session, mtype: str, days: int): diff --git a/app/db/subscribe_oper.py b/app/db/subscribe_oper.py index 8525ed81..7e8623b8 100644 --- a/app/db/subscribe_oper.py +++ b/app/db/subscribe_oper.py @@ -95,6 +95,12 @@ class SubscribeOper(DbOper): """ return Subscribe.get_by_tmdbid(self._db, tmdbid=tmdbid, season=season) + def list_by_username(self, username: str, state: str = None, mtype: str = None) -> List[Subscribe]: + """ + 获取指定用户的订阅 + """ + return Subscribe.list_by_username(self._db, username=username, state=state, mtype=mtype) + def list_by_type(self, mtype: str, days: int = 7) -> Subscribe: """ 获取指定类型的订阅 From 40a612c327259f56dc41929d3e56d55739c0308e Mon Sep 17 00:00:00 2001 From: thsrite Date: Mon, 22 Apr 2024 15:57:34 +0800 Subject: [PATCH 3/3] fix --- app/db/subscribe_oper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/db/subscribe_oper.py b/app/db/subscribe_oper.py index 7e8623b8..e7895982 100644 --- a/app/db/subscribe_oper.py +++ b/app/db/subscribe_oper.py @@ -89,7 +89,7 @@ class SubscribeOper(DbOper): subscribe.update(self._db, payload) return subscribe - def get_by_tmdbid(self, tmdbid: int, season: int = None) -> List[Subscribe]: + def list_by_tmdbid(self, tmdbid: int, season: int = None) -> List[Subscribe]: """ 获取指定tmdb_id的订阅 """