Files
life-echo/api/app/features/quota/router.py
Sully 53e0065e3e refactor(api): TOML 配置 SSOT、统一错误契约、Auth/事务加固与可观测性 (#33)
配置 SSOT(TOML + .env)
统一错误契约
Auth 与事务边界
Redis / Celery 可靠性:业务 Redis(DB/0)与 Celery broker/backend(DB/1)显式拆分;连接池、sync client
可观测性(OpenTelemetry + LGTM)
2026-05-22 13:44:50 +08:00

28 lines
806 B
Python

"""
配额检查路由。
"""
from fastapi import APIRouter, Depends
from app.core.dependencies import get_current_user
from app.core.openapi import error_responses
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=error_responses(401, 403, 404, 429),
)
@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)