新增 API 测试用例,修复失效接口问题
This commit is contained in:
@@ -7,11 +7,9 @@ from app.services.tjnetwork import (
|
||||
add_region,
|
||||
add_service_area,
|
||||
add_virtual_district,
|
||||
# calculate_district_metering_area,
|
||||
calculate_district_metering_area_for_network,
|
||||
calculate_district_metering_area_for_nodes,
|
||||
calculate_district_metering_area_for_region,
|
||||
# calculate_region,
|
||||
calculate_service_area,
|
||||
calculate_virtual_district,
|
||||
delete_district_metering_area,
|
||||
@@ -19,13 +17,11 @@ from app.services.tjnetwork import (
|
||||
delete_service_area,
|
||||
delete_virtual_district,
|
||||
generate_district_metering_area,
|
||||
# generate_region,
|
||||
generate_service_area,
|
||||
generate_sub_district_metering_area,
|
||||
generate_virtual_district,
|
||||
get_all_district_metering_area_ids,
|
||||
get_all_district_metering_areas,
|
||||
# get_all_regions,
|
||||
get_all_service_areas,
|
||||
get_all_virtual_districts,
|
||||
get_district_metering_area,
|
||||
@@ -48,18 +44,6 @@ router = APIRouter()
|
||||
# region 32
|
||||
############################################################
|
||||
|
||||
@router.get(
|
||||
"/calculateregion/",
|
||||
summary="计算区域",
|
||||
description="计算指定水网在指定时间步长的区域分区"
|
||||
)
|
||||
async def fastapi_calculate_region(
|
||||
network: str = Query(..., description="管网名称(或数据库名称)"),
|
||||
time_index: int = Query(..., description="时间步长索引", ge=0)
|
||||
) -> dict[str, Any]:
|
||||
"""计算区域分区。"""
|
||||
return calculate_region(network, time_index)
|
||||
|
||||
@router.get(
|
||||
"/getregionschema/",
|
||||
summary="获取区域属性架构",
|
||||
@@ -125,62 +109,11 @@ async def fastapi_delete_region(
|
||||
props = await req.json()
|
||||
return delete_region(network, ChangeSet(props))
|
||||
|
||||
@router.get(
|
||||
"/getallregions/",
|
||||
summary="获取所有区域",
|
||||
description="获取指定水网中的所有区域信息"
|
||||
)
|
||||
async def fastapi_get_all_regions(
|
||||
network: str = Query(..., description="管网名称(或数据库名称)")
|
||||
) -> list[dict[str, Any]]:
|
||||
"""获取所有区域的信息列表。"""
|
||||
return get_all_regions(network)
|
||||
|
||||
@router.post(
|
||||
"/generateregion/",
|
||||
response_model=None,
|
||||
summary="生成区域分区",
|
||||
description="根据参数自动生成水网的区域分区"
|
||||
)
|
||||
async def fastapi_generate_region(
|
||||
network: str = Query(..., description="管网名称(或数据库名称)"),
|
||||
inflate_delta: float = Query(..., description="膨胀参数")
|
||||
) -> ChangeSet:
|
||||
"""生成区域分区。"""
|
||||
return generate_region(network, inflate_delta)
|
||||
|
||||
|
||||
############################################################
|
||||
# district_metering_area 33
|
||||
############################################################
|
||||
|
||||
@router.get(
|
||||
"/calculatedistrictmeteringarea/",
|
||||
summary="计算DMA分区",
|
||||
description="计算指定节点集的区域计量(DMA)分区方案"
|
||||
)
|
||||
async def fastapi_calculate_district_metering_area(
|
||||
network: str = Query(..., description="管网名称(或数据库名称)"),
|
||||
req: Request = None
|
||||
) -> list[list[str]]:
|
||||
"""
|
||||
计算DMA分区。
|
||||
|
||||
请求体格式:
|
||||
{
|
||||
"nodes": 节点ID列表(list[str]),
|
||||
"part_count": 分区数量(int),
|
||||
"part_type": 分区类型(int)
|
||||
}
|
||||
"""
|
||||
props = await req.json()
|
||||
nodes = props["nodes"]
|
||||
part_count = props["part_count"]
|
||||
part_type = props["part_type"]
|
||||
return calculate_district_metering_area(
|
||||
network, nodes, part_count, part_type
|
||||
)
|
||||
|
||||
@router.get(
|
||||
"/calculatedistrictmeteringareaforregion/",
|
||||
summary="计算区域内DMA分区",
|
||||
@@ -368,14 +301,13 @@ async def fastapi_generate_sub_district_metering_area(
|
||||
@router.get(
|
||||
"/calculateservicearea/",
|
||||
summary="计算服务区",
|
||||
description="计算指定水网在指定时间步长的服务区分区"
|
||||
description="计算指定水网的服务区分区,返回全部时间步结果"
|
||||
)
|
||||
async def fastapi_calculate_service_area(
|
||||
network: str = Query(..., description="管网名称(或数据库名称)"),
|
||||
time_index: int = Query(..., description="时间步长索引", ge=0)
|
||||
) -> dict[str, Any]:
|
||||
"""计算服务区分区。"""
|
||||
return calculate_service_area(network, time_index)
|
||||
) -> list[dict[str, list[str]]]:
|
||||
"""计算服务区分区,返回全部时间步结果。"""
|
||||
return calculate_service_area(network)
|
||||
|
||||
@router.get(
|
||||
"/getserviceareaschema/",
|
||||
|
||||
Reference in New Issue
Block a user