From 3601ccdb4c41b757a1da5192155b2bd1cbded90d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Fri, 5 Aug 2022 21:21:28 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20=E4=BF=AE=E5=A4=8D=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=95=B0=E6=8D=AE=E5=BA=93=E8=AF=BB=E5=86=99=E7=9A=84?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/cookies/repositories.py | 10 +++++----- apps/user/repositories.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/cookies/repositories.py b/apps/cookies/repositories.py index 64b7c30c..c26dbcbf 100644 --- a/apps/cookies/repositories.py +++ b/apps/cookies/repositories.py @@ -31,21 +31,21 @@ class CookiesRepository: if region == RegionEnum.HYPERION: statement = select(HyperionCookie).where(HyperionCookie.user_id == user_id) results = await session.exec(statement) - db_cookies = results.one() + db_cookies = results.one()[0] if db_cookies is None: raise CookiesNotFoundError(user_id) - db_cookies.cookie = cookies - await session.add(db_cookies) + db_cookies.cookies = cookies + session.add(db_cookies) await session.commit() await session.refresh(db_cookies) elif region == RegionEnum.HOYOLAB: statement = select(HyperionCookie).where(HyperionCookie.user_id == user_id) results = await session.add(statement) - db_cookies = results.one() + db_cookies = results.one()[0] if db_cookies is None: raise CookiesNotFoundError(user_id) db_cookies.cookie = cookies - await session.add(db_cookies) + session.add(db_cookies) await session.commit() await session.refresh(db_cookies) else: diff --git a/apps/user/repositories.py b/apps/user/repositories.py index d49c5657..3bfc8809 100644 --- a/apps/user/repositories.py +++ b/apps/user/repositories.py @@ -18,12 +18,12 @@ class UserRepository: statement = select(User).where(User.user_id == user_id) results = await session.exec(statement) user = results.first() - return user + return user[0] async def update_user(self, user: User): async with self.mysql.Session() as session: session = cast(AsyncSession, session) - await session.add(user) + session.add(user) await session.commit() await session.refresh(user)