feat:新增大屏存取发布接口

This commit is contained in:
2026-10-11 08:27:30 -07:00
parent dadd797391
commit afc07ba695
23 changed files with 2672 additions and 36 deletions
+29
View File
@@ -0,0 +1,29 @@
"""编辑态数据源取数:登录用户传 URL,服务端替浏览器请求,responsePath / transform 仍由前端做"""
from typing import Annotated, Any, Literal
from fastapi import APIRouter, Depends
from pydantic import BaseModel, Field
from app.common.response import ApiResponse, success_response
from app.core.auth import get_current_user
from app.schemas.user import CurrentUser
from app.services.datasource_proxy import fetch_json
router = APIRouter(prefix="/datasource", tags=["DataSource"])
class DataSourceFetch(BaseModel):
url: str = Field(min_length=1, max_length=4096)
method: Literal["GET", "POST"] = "GET"
params: dict[str, Any] | None = None
headers: dict[str, Any] | None = None
@router.post("/fetch")
async def fetch_datasource(
body: DataSourceFetch,
user: Annotated[CurrentUser, Depends(get_current_user)],
) -> ApiResponse[dict[str, Any] | list[Any]]:
data = await fetch_json(body.url, body.method, body.params, body.headers)
return success_response(data)