feat: 管理端用户列表显示姓名和公司
This commit is contained in:
@@ -369,6 +369,7 @@ def poll_qr_login(db: Session, attempt_id: str) -> dict:
|
||||
def fetch_home_summary(db: Session, employee_id: str, client_factory=EunivClient) -> dict:
|
||||
data = _live(db, employee_id, client_factory, lambda client: _apply_hours_source(client, client.home_summary()))
|
||||
_remember_month_hours(db, employee_id, data)
|
||||
_remember_profile(db, employee_id, data)
|
||||
return data
|
||||
|
||||
|
||||
@@ -470,6 +471,34 @@ def _remember_month_hours(db: Session, employee_id: str, payload: dict) -> None:
|
||||
db.commit()
|
||||
|
||||
|
||||
def _profile_text(value: object, limit: int) -> str:
|
||||
if not isinstance(value, str):
|
||||
return ""
|
||||
return value.strip()[:limit]
|
||||
|
||||
|
||||
def _remember_profile(db: Session, employee_id: str, payload: dict) -> None:
|
||||
"""首页已经取到姓名和部门时,顺手写回用户列表。不记录职级。"""
|
||||
if not isinstance(payload, dict):
|
||||
return
|
||||
name = _profile_text(payload.get("name"), 64)
|
||||
company = _profile_text(payload.get("department"), 300)
|
||||
if not name and not company:
|
||||
return
|
||||
account = db.get(Account, employee_id)
|
||||
if account is None:
|
||||
return
|
||||
changed = False
|
||||
if name and account.user_name != name:
|
||||
account.user_name = name
|
||||
changed = True
|
||||
if company and account.company != company:
|
||||
account.company = company
|
||||
changed = True
|
||||
if changed:
|
||||
db.commit()
|
||||
|
||||
|
||||
def _hour_fields(data: dict) -> dict:
|
||||
fields = {
|
||||
"hours_source": data.get("hours_source") or "api",
|
||||
|
||||
Reference in New Issue
Block a user