2021.4 #19
@ -6,6 +6,7 @@ from cpl.console import Console
|
|||||||
from cpl.dependency_injection import ServiceProviderABC
|
from cpl.dependency_injection import ServiceProviderABC
|
||||||
from cpl.logging import LoggerABC
|
from cpl.logging import LoggerABC
|
||||||
from model.user_repo_abc import UserRepoABC
|
from model.user_repo_abc import UserRepoABC
|
||||||
|
from model.user_repo import UserRepo
|
||||||
|
|
||||||
|
|
||||||
class Application(ApplicationABC):
|
class Application(ApplicationABC):
|
||||||
@ -23,4 +24,13 @@ class Application(ApplicationABC):
|
|||||||
self._logger.debug(__name__, f'Host: {self._configuration.environment.host_name}')
|
self._logger.debug(__name__, f'Host: {self._configuration.environment.host_name}')
|
||||||
self._logger.debug(__name__, f'Environment: {self._configuration.environment.environment_name}')
|
self._logger.debug(__name__, f'Environment: {self._configuration.environment.environment_name}')
|
||||||
self._logger.debug(__name__, f'Customer: {self._configuration.environment.customer}')
|
self._logger.debug(__name__, f'Customer: {self._configuration.environment.customer}')
|
||||||
self._services.get_service(UserRepoABC).add_test_user()
|
|
||||||
|
user_repo: UserRepo = self._services.get_service(UserRepoABC)
|
||||||
|
user_repo.add_test_user()
|
||||||
|
Console.write_line('Users:')
|
||||||
|
for user in user_repo.get_users():
|
||||||
|
Console.write_line(user.Id, user.Name, user.City_Id, user.City.Id, user.City.Name, user.City.ZIP)
|
||||||
|
|
||||||
|
Console.write_line('Cities:')
|
||||||
|
for city in user_repo.get_cities():
|
||||||
|
Console.write_line(city.Id, city.Name, city.ZIP)
|
||||||
|
@ -21,3 +21,9 @@ class UserRepo(UserRepoABC):
|
|||||||
user = UserModel('TestUser', city)
|
user = UserModel('TestUser', city)
|
||||||
self._session.add(user)
|
self._session.add(user)
|
||||||
self._session.commit()
|
self._session.commit()
|
||||||
|
|
||||||
|
def get_users(self) -> list[UserModel]:
|
||||||
|
return self._session.query(UserModel).all()
|
||||||
|
|
||||||
|
def get_cities(self) -> list[CityModel]:
|
||||||
|
return self._session.query(CityModel).all()
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
|
|
||||||
|
from .user_model import UserModel
|
||||||
|
|
||||||
|
|
||||||
class UserRepoABC(ABC):
|
class UserRepoABC(ABC):
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def __init__(self): pass
|
def __init__(self): pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def get_users(self) -> list[UserModel]: pass
|
||||||
|
Loading…
Reference in New Issue
Block a user