2021.4 #19

Merged
edraft merged 237 commits from 2021.4 into master 2021-04-01 10:13:33 +02:00
3 changed files with 22 additions and 1 deletions
Showing only changes of commit d0812bcf5c - Show all commits

View File

@ -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)

View File

@ -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()

View File

@ -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