feat:图表交互
This commit is contained in:
+14
-6
@@ -1,15 +1,15 @@
|
||||
"""匿名接口,统一放在 /api/public 下,一眼能看出哪些不鉴权"""
|
||||
|
||||
from typing import Any
|
||||
from typing import Annotated, Any
|
||||
|
||||
from fastapi import APIRouter
|
||||
from fastapi import APIRouter, Query
|
||||
from fastapi.responses import FileResponse
|
||||
|
||||
from app.api.screens import Service
|
||||
from app.common.response import ApiResponse, success_response
|
||||
from app.core.exceptions import BizException
|
||||
from app.schemas.saved_screen import PublicScreen
|
||||
from app.services.screens import public_page
|
||||
from app.services.screens import LIVE_VARS_MAX_CHARS, public_page
|
||||
|
||||
router = APIRouter(prefix="/public", tags=["Public"])
|
||||
|
||||
@@ -32,11 +32,19 @@ async def get_public_screen(
|
||||
|
||||
@router.get("/screens/{share_id}/datasources/{datasource_id}")
|
||||
async def fetch_public_datasource(
|
||||
share_id: str, datasource_id: str, service: Service
|
||||
share_id: str,
|
||||
datasource_id: str,
|
||||
service: Service,
|
||||
variables: Annotated[
|
||||
str | None, Query(alias="vars", max_length=LIVE_VARS_MAX_CHARS)
|
||||
] = None,
|
||||
) -> ApiResponse[dict[str, Any] | list[Any]]:
|
||||
"""线上取数:地址取自已发布快照里的数据源配置,前端只传 ID"""
|
||||
"""线上取数:地址取自已发布快照里的数据源配置,前端只传 ID
|
||||
|
||||
vars 是 JSON 对象 {变量ID: 值},只传该数据源 params 里引用到的变量;服务端只代入 params
|
||||
"""
|
||||
return success_response(
|
||||
await service.fetch_live_datasource(share_id, datasource_id)
|
||||
await service.fetch_live_datasource(share_id, datasource_id, variables)
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user