32 lines
923 B
Python
32 lines
923 B
Python
"""
|
|
配额检查路由。
|
|
"""
|
|
|
|
from fastapi import APIRouter, Depends
|
|
|
|
from app.core.dependencies import get_current_user
|
|
from app.features.quota.deps import get_quota_service
|
|
from app.features.quota.schemas import QuotaCheckResponse
|
|
from app.features.quota.service import QuotaService
|
|
from app.features.user.models import User
|
|
|
|
router = APIRouter(
|
|
prefix="/api/quota",
|
|
tags=["quota"],
|
|
responses={
|
|
401: {"description": "认证失败"},
|
|
403: {"description": "权限不足"},
|
|
404: {"description": "资源不存在"},
|
|
429: {"description": "配额已用尽"},
|
|
},
|
|
)
|
|
|
|
|
|
@router.get("/check", response_model=QuotaCheckResponse)
|
|
async def check_quota(
|
|
current_user: User = Depends(get_current_user),
|
|
service: QuotaService = Depends(get_quota_service),
|
|
):
|
|
"""检查用户配额使用情况"""
|
|
return await service.check(current_user.id, current_user.subscription_type)
|