feat: 考试和培训可点开明细,考试列表显示是否通过
This commit is contained in:
@@ -122,6 +122,18 @@ def submit_jigsaw(db: Session, attempt_id: str, offset: int) -> dict:
|
||||
|
||||
def fetch_home(db: Session, employee_id: str, client_factory=EunivClient) -> dict:
|
||||
"""向 e 学现查首页信息。个人信息只出现在返回值里,不写入数据库。凭证变化时更新密文。"""
|
||||
return _live(db, employee_id, client_factory, lambda client: client.home_snapshot())
|
||||
|
||||
|
||||
def fetch_exam_detail(db: Session, employee_id: str, path: str, client_factory=EunivClient) -> dict:
|
||||
return _live(db, employee_id, client_factory, lambda client: client.exam_detail(path))
|
||||
|
||||
|
||||
def fetch_training_detail(db: Session, employee_id: str, path: str, client_factory=EunivClient) -> dict:
|
||||
return _live(db, employee_id, client_factory, lambda client: client.training_detail(path))
|
||||
|
||||
|
||||
def _live(db: Session, employee_id: str, client_factory, read):
|
||||
account = db.get(Account, employee_id)
|
||||
if account is None:
|
||||
raise RuntimeError("请先登录")
|
||||
@@ -136,13 +148,13 @@ def fetch_home(db: Session, employee_id: str, client_factory=EunivClient) -> dic
|
||||
except ManualJigsaw:
|
||||
raise RuntimeError("登录需要重新验证,请重新登录") from None
|
||||
try:
|
||||
data = client.home_snapshot()
|
||||
data = read(client)
|
||||
except SessionExpired:
|
||||
try:
|
||||
client.authorize(client.login())
|
||||
except ManualJigsaw:
|
||||
raise RuntimeError("登录需要重新验证,请重新登录") from None
|
||||
data = client.home_snapshot()
|
||||
data = read(client)
|
||||
updated = client.export_credential()
|
||||
if _dump(updated) != _dump(credential):
|
||||
account.credential_cipher = encrypt_secret(_dump(updated))
|
||||
|
||||
Reference in New Issue
Block a user