feat(562-2): D03 노선 정본 GET · PUT 응답에 year_start(사업연도 시작) — 조각 연도 고름 처음 값
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -269,10 +269,13 @@ async def _load(connection: Any, project_id: UUID) -> tuple[dict[str, Any] | Non
|
||||
return legacy, legacy is not None
|
||||
|
||||
|
||||
def _view(network: dict[str, Any] | None, legacy: bool, base: dict[str, Any]) -> dict[str, Any]:
|
||||
def _view(
|
||||
network: dict[str, Any] | None, legacy: bool, base: dict[str, Any], year_start: int | None
|
||||
) -> dict[str, Any]:
|
||||
return {
|
||||
"status": "success",
|
||||
"base": base,
|
||||
"year_start": year_start,
|
||||
"network": network,
|
||||
"derived": derive(network) if network else None,
|
||||
"legacy": legacy,
|
||||
@@ -284,8 +287,13 @@ async def get_plan_network(project_id: UUID) -> dict[str, Any]:
|
||||
base = await plan_base.load_base(project_id)
|
||||
async with get_db_pool().acquire() as connection:
|
||||
network, legacy = await _load(connection, project_id)
|
||||
async with connection.cursor(aiomysql.DictCursor) as cursor:
|
||||
await cursor.execute(
|
||||
"SELECT project_year FROM projects WHERE id = %s", (str(project_id),)
|
||||
)
|
||||
row = await cursor.fetchone()
|
||||
try:
|
||||
return _view(network, legacy, base)
|
||||
return _view(network, legacy, base, row["project_year"] if row else None)
|
||||
except NetworkError as error:
|
||||
raise HTTPException(status_code=409, detail=f"저장된 노선이 틀립니다 — {error}") from error
|
||||
|
||||
@@ -425,4 +433,4 @@ async def put_plan_network(
|
||||
except Exception:
|
||||
await connection.rollback()
|
||||
raise
|
||||
return {**_view(network, False, base), "derived": derived}
|
||||
return {**_view(network, False, base, project["project_year"]), "derived": derived}
|
||||
|
||||
Reference in New Issue
Block a user