from fastapi import APIRouter, Depends from app.core.response import ApiResponse, ok from app.core.user_context import UserContext, get_user_context from app.schemas.auth import AuthMeResponse router = APIRouter() @router.get("/me", response_model=ApiResponse[AuthMeResponse]) async def auth_me(ctx: UserContext = Depends(get_user_context)): """当前用户:转发 Authorization 到 Django 用户中心,并返回标准化后的用户信息。""" profile = ctx.profile or {} return ok( AuthMeResponse( user_id=ctx.user_id, source=ctx.auth_source, username=ctx.username, display_name=ctx.display_name, tenant_id=ctx.tenant_id, role=ctx.role, phone=profile.get("phone"), avatar=profile.get("avatar"), gender=profile.get("gender"), institution=profile.get("institution") or profile.get("institution_id"), institution_id=profile.get("institution_id") or profile.get("institution"), institution_name=profile.get("institution_name"), department=profile.get("department") or profile.get("department_id"), department_id=profile.get("department_id") or profile.get("department"), department_name=profile.get("department_name"), title_name=profile.get("title_name"), major=profile.get("major"), training_stage=profile.get("training_stage"), learning_target=profile.get("learning_target"), competency_profile=profile.get("competency_profile"), weak_dimensions=profile.get("weak_dimensions"), strong_dimensions=profile.get("strong_dimensions"), ai_preference=profile.get("ai_preference"), total_training_count=profile.get("total_training_count"), total_case_count=profile.get("total_case_count"), current_level=profile.get("current_level"), status=profile.get("status"), last_login=profile.get("last_login"), last_login_time=profile.get("last_login_time"), is_superuser=profile.get("is_superuser"), is_staff=profile.get("is_staff"), is_active=profile.get("is_active"), date_joined=profile.get("date_joined"), created_at=profile.get("created_at"), updated_at=profile.get("updated_at"), ) )