Files
g0v0-server/app/router/me.py
2025-07-24 18:45:08 +08:00

31 lines
835 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from __future__ import annotations
from typing import Literal
from app.database import (
User as DBUser,
)
from app.dependencies import get_current_user, get_db
from app.models.user import (
User as ApiUser,
)
from app.utils import convert_db_user_to_api_user
from .api_router import router
from fastapi import Depends
from sqlalchemy.orm import Session
@router.get("/me/{ruleset}", response_model=ApiUser)
@router.get("/me/", response_model=ApiUser)
async def get_user_info_default(
ruleset: Literal["osu", "taiko", "fruits", "mania"] = "osu",
current_user: DBUser = Depends(get_current_user),
db: Session = Depends(get_db),
):
"""获取当前用户信息默认使用osu模式"""
# 默认使用osu模式
api_user = convert_db_user_to_api_user(current_user, ruleset, db)
return api_user