From 15f50253a3160c1d05a8a9b7f4a2368bd41f12ac 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, 17 Mar 2023 17:45:11 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20instance=20`PlayerInfoSQLM?= =?UTF-8?q?odel`=20is=20not=20persisted?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/services/players/services.py | 4 ++-- plugins/account/players.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/services/players/services.py b/core/services/players/services.py index 1397b91..aa1d447 100644 --- a/core/services/players/services.py +++ b/core/services/players/services.py @@ -180,5 +180,5 @@ class PlayerInfoService(BaseService): async def add(self, player_info: PlayerInfo): await self._players_info_repository.add(PlayerInfoSQLModel.from_orm(player_info)) - async def delete(self, player_info: PlayerInfo): - await self._players_info_repository.delete(PlayerInfoSQLModel.from_orm(player_info)) + async def delete(self, player_info: PlayerInfoSQLModel): + await self._players_info_repository.delete(player_info) diff --git a/plugins/account/players.py b/plugins/account/players.py index 3aab60c..7df65b9 100644 --- a/plugins/account/players.py +++ b/plugins/account/players.py @@ -218,7 +218,9 @@ class PlayersManagesPlugin(Plugin): cookies = await self.cookies_service.get(player.user_id, player.account_id, player.region) if cookies: await self.cookies_service.delete(cookies) - await self.player_info_service.delete(player_info) + player_info = await self.player_info_service.get_form_sql(player) + if player_info is not None: + await self.player_info_service.delete(player_info) await callback_query.edit_message_text( f"成功删除 {player.player_id} ", reply_markup=InlineKeyboardMarkup(buttons) )