-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
LLearn/infrastructure/database/repositories/user_repository_impl.py
Lines 24 to 53 in 66693cb
| async def save(self, user: User) -> User: | |
| """ | |
| 사용자 저장 | |
| Args: | |
| user: Domain User Entity | |
| Returns: | |
| User: 저장된 사용자 엔티티 | |
| """ | |
| # 1. Domain Entity → SQLAlchemy Model 변환 | |
| user_model = UserModel( | |
| id=str(user.id), # UUID → str | |
| email=user.email.value, # Email VO → str | |
| nickname=user.nickname, | |
| hashed_password=str(user.hashed_password), # Password VO → str | |
| is_active=user.is_active, | |
| is_admin=user.is_admin, | |
| created_at=user.created_at, | |
| updated_at=user.updated_at | |
| ) | |
| # 2. DB에 저장 | |
| self.session.add(user_model) # 메모리에 객체 추가(DB접근X) | |
| await self.session.commit() # 실제 DB 작성, DB 접근 O | |
| await self.session.refresh(user_model) # DB에서 생성된 값들 다시 로드 | |
| # 3. SQLAlchemy Model → Domain Entity 변환 | |
| return self._model_to_entity(user_model) | |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels