fix(entry-modules): persist route path updates
This commit is contained in:
@@ -17,6 +17,7 @@ class EntryModuleCreateDTO(BaseModel):
|
|||||||
name: str = Field(..., description="模块名称")
|
name: str = Field(..., description="模块名称")
|
||||||
description: str | None = Field(None, description="模块描述")
|
description: str | None = Field(None, description="模块描述")
|
||||||
path: 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="地区配置")
|
areas: list[EntryModuleAreaDTO] | None = Field(None, description="地区配置")
|
||||||
|
|
||||||
|
|
||||||
@@ -26,4 +27,5 @@ class EntryModuleUpdateDTO(BaseModel):
|
|||||||
name: str | None = Field(None, description="模块名称")
|
name: str | None = Field(None, description="模块名称")
|
||||||
description: str | None = Field(None, description="模块描述")
|
description: str | None = Field(None, description="模块描述")
|
||||||
path: 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="地区配置")
|
areas: list[EntryModuleAreaDTO] | None = Field(None, description="地区配置")
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ class EntryModuleAdminServiceImpl(IEntryModuleAdminService):
|
|||||||
|
|
||||||
async def CreateModule(self, Body: EntryModuleCreateDTO) -> EntryModuleVO:
|
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:
|
async with GetAsyncSession() as Session:
|
||||||
try:
|
try:
|
||||||
row = (
|
row = (
|
||||||
@@ -103,7 +104,7 @@ class EntryModuleAdminServiceImpl(IEntryModuleAdminService):
|
|||||||
{
|
{
|
||||||
"name": Body.name.strip(),
|
"name": Body.name.strip(),
|
||||||
"description": (Body.description or "").strip() or None,
|
"description": (Body.description or "").strip() or None,
|
||||||
"route_path": (Body.path or "").strip() or None,
|
"route_path": route_path,
|
||||||
"icon_path": None,
|
"icon_path": None,
|
||||||
"areas": self._areasJson(Body.areas),
|
"areas": self._areasJson(Body.areas),
|
||||||
"sort_order": await self._nextSortOrder(Session),
|
"sort_order": await self._nextSortOrder(Session),
|
||||||
@@ -119,6 +120,7 @@ class EntryModuleAdminServiceImpl(IEntryModuleAdminService):
|
|||||||
async def UpdateModule(self, ModuleId: int, Body: EntryModuleUpdateDTO) -> EntryModuleVO:
|
async def UpdateModule(self, ModuleId: int, Body: EntryModuleUpdateDTO) -> EntryModuleVO:
|
||||||
"""更新入口模块。"""
|
"""更新入口模块。"""
|
||||||
current = await self._getModuleRow(ModuleId)
|
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:
|
async with GetAsyncSession() as Session:
|
||||||
row = (
|
row = (
|
||||||
await Session.execute(
|
await Session.execute(
|
||||||
@@ -140,7 +142,7 @@ class EntryModuleAdminServiceImpl(IEntryModuleAdminService):
|
|||||||
"module_id": ModuleId,
|
"module_id": ModuleId,
|
||||||
"name": Body.name.strip() if Body.name is not None else current["name"],
|
"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"]),
|
"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"]),
|
"areas": self._areasJson(Body.areas) if Body.areas is not None else self._areasJson(current["areas"]),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user