service_man/api/service/user.py

23 lines
682 B
Python
Raw Normal View History

2024-03-04 07:12:29 +03:00
from uuid import uuid4
from model.user import User
from repository.user import UserRepository
class UserService:
def __init__(self, user_repository: UserRepository) -> None:
self._repository: UserRepository = user_repository
def get_users(self):
return self._repository.get_all()
def get_user_by_id(self, user_id: int) -> User:
return self._repository.get_by_id(user_id)
async def create_user(self) -> User:
uid = uuid4()
return await self._repository.add(email=f"{uid}@email.com", password="pwd")
async def delete_user_by_id(self, user_id: int) -> None:
return await self._repository.delete_by_id(user_id)