Added logic to list game ident users #366

This commit is contained in:
2023-09-25 20:37:30 +02:00
parent ca5a6c81b8
commit b53ddb1351
7 changed files with 108 additions and 0 deletions

View File

@@ -14,6 +14,10 @@ class UserGameIdentRepositoryABC(ABC):
def get_user_game_idents(self) -> List[UserGameIdent]:
pass
@abstractmethod
def get_user_game_idents_by_game_server_id(self, id: int) -> List[UserGameIdent]:
pass
@abstractmethod
def get_user_game_ident_by_id(self, id: int) -> UserGameIdent:
pass

View File

@@ -49,6 +49,15 @@ class UserGameIdent(TableABC):
"""
)
@staticmethod
def get_select_by_game_server_id_string(id: int) -> str:
return str(
f"""
SELECT * FROM `UserGameIdents`
WHERE `GameServerId` = {id};
"""
)
@staticmethod
def get_select_by_id_string(id: int) -> str:
return str(

View File

@@ -51,6 +51,19 @@ class UserGameIdentRepositoryService(UserGameIdentRepositoryABC):
return joins
def get_user_game_idents_by_game_server_id(self, game_server_id: int) -> List[UserGameIdent]:
joins = List(UserGameIdent)
self._logger.trace(
__name__,
f"Send SQL command: {UserGameIdent.get_select_by_game_server_id_string(game_server_id)}",
)
results = self._context.select(UserGameIdent.get_select_by_game_server_id_string(game_server_id))
for result in results:
self._logger.trace(__name__, f"Get UserGameIdent with id {result[0]}")
joins.append(self._from_result(result))
return joins
def get_user_game_ident_by_id(self, id: int) -> UserGameIdent:
self._logger.trace(
__name__,