feat: add template detail and config APIs
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
from ..schemas.template import DataSourcePayload
|
||||
|
||||
|
||||
router = APIRouter(prefix="/api/data-sources", tags=["data-sources"])
|
||||
|
||||
DATA_SOURCES: list[dict] = [
|
||||
{"code": "policy", "name": "政策文件", "description": "政策法规、制度文件等资料"},
|
||||
{"code": "business_data", "name": "业务数据", "description": "业务系统导出的结构化数据"},
|
||||
{"code": "research", "name": "调研材料", "description": "访谈、问卷、调研纪要等非结构化资料"},
|
||||
]
|
||||
|
||||
|
||||
@router.get("")
|
||||
def list_data_sources():
|
||||
return {"data": DATA_SOURCES, "message": "ok"}
|
||||
|
||||
|
||||
@router.post("")
|
||||
def create_data_source(payload: DataSourcePayload):
|
||||
if any(item["code"] == payload.code for item in DATA_SOURCES):
|
||||
raise HTTPException(status_code=400, detail="数据源编码已存在")
|
||||
|
||||
item = payload.model_dump()
|
||||
DATA_SOURCES.append(item)
|
||||
return {"data": item, "message": "ok"}
|
||||
Reference in New Issue
Block a user