配置 SSOT(TOML + .env) 统一错误契约 Auth 与事务边界 Redis / Celery 可靠性:业务 Redis(DB/0)与 Celery broker/backend(DB/1)显式拆分;连接池、sync client 可观测性(OpenTelemetry + LGTM)
31 lines
920 B
Python
31 lines
920 B
Python
"""
|
|
订阅计划路由。
|
|
"""
|
|
|
|
from fastapi import APIRouter
|
|
|
|
from app.core.openapi import error_responses
|
|
from app.features.plan.deps import CurrentUserDep, PlanServiceDep
|
|
from app.features.plan.schemas import CurrentPlanResponse, PlanResponse
|
|
|
|
router = APIRouter(
|
|
prefix="/api/plans",
|
|
tags=["plans"],
|
|
responses=error_responses(401, 404),
|
|
)
|
|
|
|
|
|
@router.get("", response_model=list[PlanResponse])
|
|
def get_plans(service: PlanServiceDep) -> list[PlanResponse]:
|
|
"""获取所有可用的订阅计划(开发环境 ENABLE_TEST_PLAN=1 时包含「一分钱测试版」)。"""
|
|
return service.get_plans_for_api()
|
|
|
|
|
|
@router.get("/current", response_model=CurrentPlanResponse)
|
|
async def get_current_plan(
|
|
current_user: CurrentUserDep,
|
|
service: PlanServiceDep,
|
|
) -> CurrentPlanResponse:
|
|
"""获取当前用户的订阅计划信息"""
|
|
return await service.get_current_plan_response(current_user)
|