feat: 新增市场边界编辑并修正 Vue 列表布局
This commit is contained in:
+32
@@ -11,6 +11,7 @@ from fastapi import FastAPI, HTTPException, UploadFile
|
||||
from fastapi.responses import JSONResponse, StreamingResponse
|
||||
from pydantic import BaseModel
|
||||
|
||||
from marketgrid import layer_edit
|
||||
from toolbox import tasks
|
||||
from toolbox.tasks import ACTIVE, KINDS, LABELS, ROOT
|
||||
from toolbox.validation import SOURCES, market_options, validate
|
||||
@@ -32,6 +33,12 @@ class TaskRequest(BaseModel):
|
||||
credentials: dict | None = None
|
||||
|
||||
|
||||
class LayerWrite(BaseModel):
|
||||
path: str
|
||||
wkt: str = ""
|
||||
values: dict = {}
|
||||
|
||||
|
||||
def resolve_path(value):
|
||||
text = str(value or "").strip().strip('"')
|
||||
if not text:
|
||||
@@ -335,6 +342,31 @@ def file_stat(path: str = ""):
|
||||
return {"path": str(target), "exists": True, "size": target.stat().st_size}
|
||||
|
||||
|
||||
@app.get("/api/layer")
|
||||
def layer_document(path: str = ""):
|
||||
return layer_edit.read_layer(resolve_path(path))
|
||||
|
||||
|
||||
@app.post("/api/layer/clear")
|
||||
def layer_clear(body: LayerWrite):
|
||||
return layer_edit.clear_features(resolve_path(body.path))
|
||||
|
||||
|
||||
@app.post("/api/layer/features")
|
||||
def layer_create(body: LayerWrite):
|
||||
return layer_edit.create_feature(resolve_path(body.path), body.values, body.wkt)
|
||||
|
||||
|
||||
@app.put("/api/layer/features/{fid}")
|
||||
def layer_update(fid: int, body: LayerWrite):
|
||||
return layer_edit.update_feature(resolve_path(body.path), fid, body.values, body.wkt)
|
||||
|
||||
|
||||
@app.delete("/api/layer/features/{fid}")
|
||||
def layer_remove(fid: int, path: str = ""):
|
||||
return layer_edit.delete_feature(resolve_path(path), fid)
|
||||
|
||||
|
||||
@app.get("/api/markets")
|
||||
def market_list(path: str = ""):
|
||||
resolved = resolve_path(path)
|
||||
|
||||
Reference in New Issue
Block a user