예제 #1
0
    def create_user(self, user: UserDomain) -> UserDomain:
        now = datetime.now()

        data = User(
            name=user.name,
            password=user.get_raw_password(),
            email=user.email,
            created_at=now,
            updated_at=now,
        )

        try:
            db_session.add(data)
            db_session.commit()
        except IntegrityError as e:
            logger.info(e)
            raise DuplicateException

        response = User.query.filter(User.name == user.name).first()
        logger.info(f"user create success: {response}")

        return UserDomain.from_orm(response)
예제 #2
0
    def find_user_by_name(self, user: UserDomain) -> UserDomain:
        response = User.query.filter(User.name == user.name).first()
        logger.info(f"get user data: {response}")

        return UserDomain.from_orm(response)