def login(username: str, password: str) -> Person: """通过用户名和密码登录智学网 Args: username (str): 用户名, 可以为准考证号, 手机号 password (str): 密码 user_id (str): 用户id Raises: ArgError: 参数错误 UserOrPassError: 用户名或密码错误 UserNotFoundError: 未找到用户 LoginError: 登录错误 Exception: 账号角色未知 Returns: Person """ session = get_session(username, password) if check_is_student(session): return Student(session).set_base_info() teacher = Teacher(session).set_base_info() if teacher.role == "headteacher": teacher = Headteacher(teacher) elif teacher.role == "headmaster": teacher = Headmaster(teacher) else: raise Exception("账号是未知用户") return teacher.set_base_info()
def login_id(user_id: str, password: str) -> Person: """通过用户id和密码登录智学网 Args: user_id (str): 用户id password (str): 密码 Raises: UserOrPassError: 用户名或密码错误 UserNotFoundError: 未找到用户 LoginError: 登录错误 RoleError: 账号角色未知 Returns: Person """ session = get_session_id(user_id, password) if check_is_student(session): return Student(session).set_base_info() teacher = Teacher(session).set_base_info() if teacher.role == "headteacher": teacher = Headteacher(teacher) elif teacher.role == "headmaster": teacher = Headmaster(teacher) else: raise RoleError() return teacher.set_base_info()
def login_teacher(username: str, password: str) -> Teacher: """通过用户名和密码登录老师账号 Args: username (str): 用户名, 可以为准考证号, 手机号 password (str): 密码 Raises: UserOrPassError: 用户名或密码错误 UserNotFoundError: 未找到用户 LoginError: 登录错误 Returns: Teacher """ session = get_session(username, password) teacher = Teacher(session) return teacher.set_base_info()
def login_teacher_id(user_id: str, password: str) -> Teacher: """通过用户id和密码登录老师账号 Args: user_id (str): 用户id password (str): 密码 Raises: UserOrPassError: 用户名或密码错误 UserNotFoundError: 未找到用户 LoginError: 登录错误 Returns: Teacher """ session = get_session_id(user_id, password) teacher = Teacher(session) return teacher.set_base_info()