Pass changeset to junction set methods

This commit is contained in:
DingZQ
2022-10-15 14:38:02 +08:00
parent 848f713848
commit 981a1765ea

16
main.py
View File

@@ -208,43 +208,43 @@ async def fastapi_set_junction_elevation(network: str, junction: str, elevation:
props = {} props = {}
props['elevation'] = elevation props['elevation'] = elevation
props['id'] = junction props['id'] = junction
return set_junction(network, junction, props) return set_junction(network, ChangeSet(props))
@app.post("/setjunctionx/") @app.post("/setjunctionx/")
async def fastapi_set_junction_x(network: str, junction: str, x: float) -> ChangeSet: async def fastapi_set_junction_x(network: str, junction: str, x: float) -> ChangeSet:
props = {} props = {}
props['x'] = x props['x'] = x
props['id'] = junction props['id'] = junction
return set_junction(network, junction, props) return set_junction(network, ChangeSet(props))
@app.post("/setjunctionx/") @app.post("/setjunctionx/")
async def fastapi_set_junction_y(network: str, junction: str, y: float) -> ChangeSet: async def fastapi_set_junction_y(network: str, junction: str, y: float) -> ChangeSet:
props = {} props = {}
props['y'] = y props['y'] = y
props['id'] = junction props['id'] = junction
return set_junction(network, junction, props) return set_junction(network, ChangeSet(props))
@app.post("/setjunctioncoord/") @app.post("/setjunctioncoord/")
async def fastapi_set_junction_coord(network: str, junction: str, x, float, y: float) -> ChangeSet: async def fastapi_set_junction_coord(network: str, junction: str, x, float, y: float) -> ChangeSet:
props = {} props = {}
props['x'] = x props['x'] = x
props['y'] = y props['y'] = y
props['id'] = junction props['id'] = junction
return set_junction(network, junction, props) return set_junction(network, ChangeSet(props))
@app.post("/setjunctiondemand/") @app.post("/setjunctiondemand/")
async def fastapi_set_junction_demand(network: str, junction: str, demand: float) -> ChangeSet: async def fastapi_set_junction_demand(network: str, junction: str, demand: float) -> ChangeSet:
props = {} props = {}
props['demand'] = demand props['demand'] = demand
props['id'] = junction props['id'] = junction
return set_junction(network, junction, props) return set_junction(network, ChangeSet(props))
@app.post("/setjunctionpattern/") @app.post("/setjunctionpattern/")
async def fastapi_set_junction_pattern(network: str, junction: str, pattern: str) -> ChangeSet: async def fastapi_set_junction_pattern(network: str, junction: str, pattern: str) -> ChangeSet:
props = {} props = {}
props['pattern'] = pattern props['pattern'] = pattern
props['id'] = junction props['id'] = junction
return set_junction(network, junction, props) return set_junction(network, ChangeSet(props))
@app.get("/getjunctionproperties/") @app.get("/getjunctionproperties/")
async def fastapi_get_junction_properties(network: str, junction: str) -> dict[str, Any]: async def fastapi_get_junction_properties(network: str, junction: str) -> dict[str, Any]:
@@ -252,7 +252,7 @@ async def fastapi_get_junction_properties(network: str, junction: str) -> dict[s
@app.post("/setjunctionproperties/") @app.post("/setjunctionproperties/")
async def fastapi_set_junction_properties(network: str, junction: str, props: dict[str, Any]) -> ChangeSet: async def fastapi_set_junction_properties(network: str, junction: str, props: dict[str, Any]) -> ChangeSet:
return set_junction(network, junction, props) return set_junction(network, ChangeSet(props))
############################################################ ############################################################
# reservoir 3.[RESERVOIRS] # reservoir 3.[RESERVOIRS]