mirror of
https://github.com/PaiGramTeam/MibooGram.git
synced 2024-11-16 12:51:45 +00:00
602ce67e41
`apps` → `core`
22 lines
658 B
Python
22 lines
658 B
Python
from .models import User
|
|
from .repositories import UserRepository
|
|
|
|
|
|
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
|
|
:return: User
|
|
"""
|
|
return await self._repository.get_by_user_id(user_id)
|
|
|
|
async def update_user(self, user: User) -> User:
|
|
return await self._repository.update_user(user)
|
|
|
|
async def add_user(self, user: User) -> User:
|
|
return await self._repository.update_user(user)
|