@@ -26,7 +26,9 @@ async def get_user_by_id(self, user_id: str) -> Optional[User]:
2626
2727 async def get_user_four_pillar (self , user_id : str ) -> Optional [dict ]:
2828 """사용자의 사주 정보만 조회"""
29- query = select (User .four_pillar ).where (User .id == user_id , User .is_active == True )
29+ query = select (User .four_pillar ).where (
30+ User .id == user_id , User .is_active == True
31+ )
3032 result = await self .session .execute (query )
3133 return result .scalar_one_or_none ()
3234
@@ -50,19 +52,25 @@ async def create_user(
5052
5153 return user
5254
53- async def update_user (self , user_id : str , user_update : UserUpdate , four_pillar : Optional [FourPillar ] = None ) -> Optional [User ]:
55+ async def update_user (
56+ self ,
57+ user_id : str ,
58+ user_update : UserUpdate ,
59+ four_pillar : Optional [FourPillarDetail ] = None ,
60+ ) -> Optional [User ]:
5461 user = await self .get_user_by_id (user_id )
5562 if not user :
5663 return None
5764
5865 update_data = user_update .model_dump (exclude_unset = True )
5966 if four_pillar is not None :
60- update_data ["four_pillar" ] = four_pillar
67+ four_pillar_dict = four_pillar .model_dump ()
68+ update_data ["four_pillar" ] = four_pillar_dict
6169
6270 for field , value in update_data .items ():
6371 setattr (user , field , value )
64-
72+
6573 await self .session .flush ()
6674 await self .session .refresh (user )
67-
75+
6876 return user
0 commit comments