refactor(api): TOML 配置 SSOT、统一错误契约、Auth/事务加固与可观测性 (#33)
配置 SSOT(TOML + .env) 统一错误契约 Auth 与事务边界 Redis / Celery 可靠性:业务 Redis(DB/0)与 Celery broker/backend(DB/1)显式拆分;连接池、sync client 可观测性(OpenTelemetry + LGTM)
This commit is contained in:
@@ -7,7 +7,11 @@ from app.features.plan.catalog import (
|
||||
get_plan_by_type,
|
||||
get_plans_for_api,
|
||||
)
|
||||
from app.features.plan.schemas import CurrentPlanResponse, PlanResponse
|
||||
from app.features.plan.schemas import (
|
||||
CurrentPlanResponse,
|
||||
PlanResponse,
|
||||
PlanUsageResponse,
|
||||
)
|
||||
from app.features.quota.service import QuotaService
|
||||
from app.features.user.models import User
|
||||
|
||||
@@ -32,12 +36,12 @@ class PlanService:
|
||||
async def get_current_plan_response(self, user: User) -> CurrentPlanResponse:
|
||||
plan = get_plan_by_type(user.subscription_type)
|
||||
segment_count, chapter_count = await self._quota.get_usage(user.id)
|
||||
usage = {
|
||||
"conversations": segment_count,
|
||||
"chapters": chapter_count,
|
||||
"max_conversations": plan.max_conversations,
|
||||
"max_chapters": plan.max_chapters,
|
||||
}
|
||||
usage = PlanUsageResponse(
|
||||
conversations=segment_count,
|
||||
chapters=chapter_count,
|
||||
max_conversations=plan.max_conversations,
|
||||
max_chapters=plan.max_chapters,
|
||||
)
|
||||
expires_at = None
|
||||
if user.subscription_expires_at:
|
||||
expires_at = user.subscription_expires_at.isoformat()
|
||||
|
||||
Reference in New Issue
Block a user