refactor(api): use Annotated-style dependency injection

This commit is contained in:
MingxuanGame
2025-10-03 05:41:31 +00:00
parent 37b4eadf79
commit 346c2557cf
45 changed files with 623 additions and 577 deletions

View File

@@ -1,25 +1,24 @@
from __future__ import annotations
import hashlib
from typing import Annotated
from app.database.user import User
from app.dependencies.database import Database
from app.dependencies.storage import get_storage_service
from app.dependencies.user import get_client_user
from app.storage.base import StorageService
from app.dependencies.storage import StorageService
from app.dependencies.user import ClientUser
from app.utils import check_image
from .router import router
from fastapi import Depends, File, Security
from fastapi import File
@router.post("/avatar/upload", name="上传头像", tags=["用户", "g0v0 API"])
async def upload_avatar(
session: Database,
content: bytes = File(...),
current_user: User = Security(get_client_user),
storage: StorageService = Depends(get_storage_service),
content: Annotated[bytes, File(...)],
current_user: ClientUser,
storage: StorageService,
):
"""上传用户头像