From f3675924dcd69afe4d3cc1f3b11ac68bf2a57a1a Mon Sep 17 00:00:00 2001 From: wwwwwwwww <526125649@qq.com> Date: Fri, 26 Jun 2026 10:12:05 +0800 Subject: [PATCH] 1 --- video-gen-api/app/main.py | 88 +++------------------------------------ 1 file changed, 5 insertions(+), 83 deletions(-) diff --git a/video-gen-api/app/main.py b/video-gen-api/app/main.py index c3ec4c4c..d4698c22 100644 --- a/video-gen-api/app/main.py +++ b/video-gen-api/app/main.py @@ -400,55 +400,12 @@ async def _seed_data(): ("/generated", "素材云", "CloudOutlined", 1, "资产管理", True), ("/authorization", "授权管理", "UserOutlined", 0, "媒体关联", False), ("/consume", "消耗列表", "FileTextOutlined", 1, "媒体关联", False), - ("/popular", "爆款榜单", "ThunderboltOutlined", 0, "AI项目行业生成", False), - ("/creativeplaza", "创意广场", "GiftOutlined", 0, "AI对话生成", False), ] for path, label, icon, order, group_label, is_default in frontend_pages: existing = await db.execute( - select(MenuConfig).where( - MenuConfig.path == path, - MenuConfig.menu_target == "frontend", - ).limit(1) + select(MenuConfig).where(MenuConfig.path == path).limit(1) ) - existing_page = existing.scalar_one_or_none() - - parent_id = frontend_group_ids.get(group_label) - if parent_id: - parent_exists = await db.execute( - select(MenuConfig).where(MenuConfig.id == parent_id).limit(1) - ) - if not parent_exists.scalar_one_or_none(): - parent_id = None - if not parent_id: - group_exists = await db.execute( - select(MenuConfig).where( - MenuConfig.label == group_label, - MenuConfig.menu_type == "group", - MenuConfig.menu_target == "frontend", - ).limit(1) - ) - group_record = group_exists.scalar_one_or_none() - if group_record: - parent_id = group_record.id - - if existing_page: - needs_update = False - if existing_page.label != label: - existing_page.label = label - needs_update = True - if existing_page.icon != icon: - existing_page.icon = icon - needs_update = True - if existing_page.sort_order != order: - existing_page.sort_order = order - needs_update = True - if existing_page.is_default != is_default: - existing_page.is_default = is_default - needs_update = True - if existing_page.parent_id != parent_id: - existing_page.parent_id = parent_id - needs_update = True - else: + if not existing.scalar_one_or_none(): db.add( MenuConfig( id=generate_id(), @@ -457,7 +414,7 @@ async def _seed_data(): icon=icon, sort_order=order, is_active=True, - parent_id=parent_id, + parent_id=frontend_group_ids.get(group_label), menu_type="page", menu_target="frontend", is_default=is_default, @@ -524,42 +481,7 @@ async def _seed_data(): MenuConfig.menu_target == "admin", ).limit(1) ) - existing_page = existing.scalar_one_or_none() - - parent_id = admin_group_ids.get(parent_group) if parent_group else None - if parent_id: - parent_exists = await db.execute( - select(MenuConfig).where(MenuConfig.id == parent_id).limit(1) - ) - if not parent_exists.scalar_one_or_none(): - parent_id = None - if not parent_id and parent_group: - group_exists = await db.execute( - select(MenuConfig).where( - MenuConfig.label == parent_group, - MenuConfig.menu_type == "group", - MenuConfig.menu_target == "admin", - ).limit(1) - ) - group_record = group_exists.scalar_one_or_none() - if group_record: - parent_id = group_record.id - - if existing_page: - needs_update = False - if existing_page.label != label: - existing_page.label = label - needs_update = True - if existing_page.icon != icon: - existing_page.icon = icon - needs_update = True - if existing_page.sort_order != order: - existing_page.sort_order = order - needs_update = True - if existing_page.parent_id != parent_id: - existing_page.parent_id = parent_id - needs_update = True - else: + if not existing.scalar_one_or_none(): db.add( MenuConfig( id=generate_id(), @@ -570,7 +492,7 @@ async def _seed_data(): is_active=True, menu_type="page", menu_target="admin", - parent_id=parent_id, + parent_id=admin_group_ids.get(parent_group), ) )