예제 #1
0
def patch_emp(session: DBSes, emp: ReqPatchEmpDto, eid: int) -> DBEmp:

    db_emp = session.get_emp_by_id(eid)

    for attr in emp.fields:
        if hasattr(emp, attr):
            setattr(db_emp, attr, getattr(emp, attr))

    return db_emp
예제 #2
0
def get_emp(session: DBSes, *, login: str = None, emp_id: int = None) -> DBEmp:
    db_emp = None

    if login is not None:
        db_emp = session.get_emp_by_login(login)
    elif emp_id is not None:
        db_emp = session.get_emp_by_id(emp_id)

    if db_emp is None:
        raise DBEmpNotExistException()

    return db_emp
예제 #3
0
def delete_emp(session: DBSes, emp_id: int) -> DBEmp:
    db_emp = session.get_emp_by_id(emp_id)
    db_emp.is_delete = True
    return db_emp