43 lines
1.7 KiB
Python
43 lines
1.7 KiB
Python
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"),
|
|
institution_name=profile.get("institution_name"),
|
|
department=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"),
|
|
)
|
|
)
|