2022-08-04 13:18:23 +00:00
|
|
|
from .models import User
|
|
|
|
from .repositories import UserRepository
|
2022-07-26 10:07:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UserService:
|
|
|
|
def __init__(self, user_repository: UserRepository) -> None:
|
|
|
|
self._repository: UserRepository = user_repository
|
|
|
|
|
|
|
|
async def get_user_by_id(self, user_id: int) -> User:
|
|
|
|
"""从数据库获取用户信息
|
|
|
|
:param user_id:用户ID
|
2022-08-04 13:18:23 +00:00
|
|
|
:return: User
|
2022-07-26 10:07:31 +00:00
|
|
|
"""
|
2022-08-05 12:03:57 +00:00
|
|
|
return await self._repository.get_by_user_id(user_id)
|
|
|
|
|
2022-11-30 03:25:19 +00:00
|
|
|
async def del_user_by_id(self, user_id: int) -> User:
|
|
|
|
return await self._repository.del_user_by_id(user_id)
|
|
|
|
|
2022-08-05 12:03:57 +00:00
|
|
|
async def update_user(self, user: User) -> User:
|
|
|
|
return await self._repository.update_user(user)
|
|
|
|
|
|
|
|
async def add_user(self, user: User) -> User:
|
2022-12-01 10:40:02 +00:00
|
|
|
return await self._repository.add_user(user)
|