mirror of
https://github.com/PaiGramTeam/MibooGram.git
synced 2024-11-16 12:51:45 +00:00
🔧 修复部分数据库读写的代码错误
This commit is contained in:
parent
72b73be299
commit
3601ccdb4c
@ -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:
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user