fix(entry-modules): persist route path updates

This commit is contained in:
wren
2026-05-11 11:28:08 +08:00
parent e19f63183b
commit da2bb8310d
2 changed files with 6 additions and 2 deletions
@@ -17,6 +17,7 @@ class EntryModuleCreateDTO(BaseModel):
name: str = Field(..., description="模块名称")
description: str | None = Field(None, description="模块描述")
path: str | None = Field(None, description="前端路由路径")
route_path: str | None = Field(None, description="前端跳转路径")
areas: list[EntryModuleAreaDTO] | None = Field(None, description="地区配置")
@@ -26,4 +27,5 @@ class EntryModuleUpdateDTO(BaseModel):
name: str | None = Field(None, description="模块名称")
description: str | None = Field(None, description="模块描述")
path: str | None = Field(None, description="前端路由路径")
route_path: str | None = Field(None, description="前端跳转路径")
areas: list[EntryModuleAreaDTO] | None = Field(None, description="地区配置")
@@ -86,6 +86,7 @@ class EntryModuleAdminServiceImpl(IEntryModuleAdminService):
async def CreateModule(self, Body: EntryModuleCreateDTO) -> EntryModuleVO:
"""创建入口模块。"""
route_path = (Body.route_path if Body.route_path is not None else Body.path or "").strip() or None
async with GetAsyncSession() as Session:
try:
row = (
@@ -103,7 +104,7 @@ class EntryModuleAdminServiceImpl(IEntryModuleAdminService):
{
"name": Body.name.strip(),
"description": (Body.description or "").strip() or None,
"route_path": (Body.path or "").strip() or None,
"route_path": route_path,
"icon_path": None,
"areas": self._areasJson(Body.areas),
"sort_order": await self._nextSortOrder(Session),
@@ -119,6 +120,7 @@ class EntryModuleAdminServiceImpl(IEntryModuleAdminService):
async def UpdateModule(self, ModuleId: int, Body: EntryModuleUpdateDTO) -> EntryModuleVO:
"""更新入口模块。"""
current = await self._getModuleRow(ModuleId)
incoming_route_path = Body.route_path if Body.route_path is not None else Body.path
async with GetAsyncSession() as Session:
row = (
await Session.execute(
@@ -140,7 +142,7 @@ class EntryModuleAdminServiceImpl(IEntryModuleAdminService):
"module_id": ModuleId,
"name": Body.name.strip() if Body.name is not None else current["name"],
"description": (Body.description.strip() if Body.description is not None else current["description"]),
"route_path": (Body.path.strip() if Body.path is not None else current["path"]),
"route_path": (incoming_route_path.strip() if incoming_route_path is not None else current["path"]),
"areas": self._areasJson(Body.areas) if Body.areas is not None else self._areasJson(current["areas"]),
},
)