2026-03-18 17:18:23 +08:00
|
|
|
"""
|
|
|
|
|
配额检查路由。
|
|
|
|
|
"""
|
2026-03-19 14:36:14 +08:00
|
|
|
|
2026-03-18 17:18:23 +08:00
|
|
|
from fastapi import APIRouter, Depends
|
|
|
|
|
|
|
|
|
|
from app.core.dependencies import get_current_user
|
2026-05-22 13:44:50 +08:00
|
|
|
from app.core.openapi import error_responses
|
2026-03-18 17:18:23 +08:00
|
|
|
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"],
|
2026-05-22 13:44:50 +08:00
|
|
|
responses=error_responses(401, 403, 404, 429),
|
2026-03-18 17:18:23 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@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)
|