Esempio n. 1
0
def delete_user(session: DBSession, uid: int):
    db_user = session.get_user_by_id(uid)

    if db_user is None or db_user.is_delete is True:
        raise DBUserNotExistsException

    db_user.is_delete = True
Esempio n. 2
0
def update_user(session: DBSession, uid: int,
                user: ReqUpdateUserDTO) -> UserModel:
    db_user = session.get_user_by_id(uid)

    for attr in user.fields:
        if hasattr(user, attr):
            setattr(db_user, attr, getattr(user, attr))

    return db_user
Esempio n. 3
0
def get_user(session: DBSession,
             *,
             username: str = None,
             user_id: int = None) -> UserModel:
    db_employee = None

    if username is not None:
        db_employee = session.get_user_by_username(username)
    elif user_id is not None:
        db_employee = session.get_user_by_id(user_id)

    if db_employee is None or db_employee.is_delete is True:
        raise DBUserNotExistsException
    return db_employee