-- Organize all visible IM admin pages under the GedaDa menu hierarchy. -- This script is idempotent and preserves page/button menu IDs and permissions. SET NAMES utf8mb4; SET @now := NOW(); SET @imRootId := (SELECT `id` FROM `hg_admin_menu` WHERE `name` = 'imManager' LIMIT 1); INSERT INTO `hg_admin_menu` (`pid`, `title`, `name`, `path`, `icon`, `type`, `redirect`, `permissions`, `permission_name`, `component`, `always_show`, `active_menu`, `is_root`, `is_frame`, `frame_src`, `keep_alive`, `hidden`, `affix`, `level`, `tree`, `sort`, `remark`, `status`, `created_at`, `updated_at`) SELECT @imRootId, '用户与群组', 'imUserAndGroup', 'people', 'TeamOutlined', 1, '/im/people/user/index', '', '', 'ParentLayout', 1, '', 0, 0, '', 0, 0, 0, 2, CONCAT('tr_', @imRootId, ' '), 10, '', 1, @now, @now WHERE @imRootId IS NOT NULL AND NOT EXISTS (SELECT 1 FROM `hg_admin_menu` WHERE `name` = 'imUserAndGroup'); INSERT INTO `hg_admin_menu` (`pid`, `title`, `name`, `path`, `icon`, `type`, `redirect`, `permissions`, `permission_name`, `component`, `always_show`, `active_menu`, `is_root`, `is_frame`, `frame_src`, `keep_alive`, `hidden`, `affix`, `level`, `tree`, `sort`, `remark`, `status`, `created_at`, `updated_at`) SELECT @imRootId, '内容审核', 'imContentAudit', 'content', 'FileSearchOutlined', 1, '/im/content/private-message/index', '', '', 'ParentLayout', 1, '', 0, 0, '', 0, 0, 0, 2, CONCAT('tr_', @imRootId, ' '), 20, '', 1, @now, @now WHERE @imRootId IS NOT NULL AND NOT EXISTS (SELECT 1 FROM `hg_admin_menu` WHERE `name` = 'imContentAudit'); INSERT INTO `hg_admin_menu` (`pid`, `title`, `name`, `path`, `icon`, `type`, `redirect`, `permissions`, `permission_name`, `component`, `always_show`, `active_menu`, `is_root`, `is_frame`, `frame_src`, `keep_alive`, `hidden`, `affix`, `level`, `tree`, `sort`, `remark`, `status`, `created_at`, `updated_at`) SELECT @imRootId, '日志审计', 'imLogAudit', 'audit', 'AuditOutlined', 1, '/im/audit/operation/index', '', '', 'ParentLayout', 1, '', 0, 0, '', 0, 0, 0, 2, CONCAT('tr_', @imRootId, ' '), 30, '', 1, @now, @now WHERE @imRootId IS NOT NULL AND NOT EXISTS (SELECT 1 FROM `hg_admin_menu` WHERE `name` = 'imLogAudit'); INSERT INTO `hg_admin_menu` (`pid`, `title`, `name`, `path`, `icon`, `type`, `redirect`, `permissions`, `permission_name`, `component`, `always_show`, `active_menu`, `is_root`, `is_frame`, `frame_src`, `keep_alive`, `hidden`, `affix`, `level`, `tree`, `sort`, `remark`, `status`, `created_at`, `updated_at`) SELECT @imRootId, '平台设置', 'imSystemSettings', 'settings', 'SettingOutlined', 1, '/im/settings/tenant/index', '', '', 'ParentLayout', 1, '', 0, 0, '', 0, 0, 0, 2, CONCAT('tr_', @imRootId, ' '), 40, '', 1, @now, @now WHERE @imRootId IS NOT NULL AND NOT EXISTS (SELECT 1 FROM `hg_admin_menu` WHERE `name` = 'imSystemSettings'); SET @peopleId := (SELECT `id` FROM `hg_admin_menu` WHERE `name` = 'imUserAndGroup' LIMIT 1); SET @contentId := (SELECT `id` FROM `hg_admin_menu` WHERE `name` = 'imContentAudit' LIMIT 1); SET @auditId := (SELECT `id` FROM `hg_admin_menu` WHERE `name` = 'imLogAudit' LIMIT 1); SET @settingsId := (SELECT `id` FROM `hg_admin_menu` WHERE `name` = 'imSystemSettings' LIMIT 1); UPDATE `hg_admin_menu` SET `pid`=@imRootId, `title`='用户与群组', `path`='people', `icon`='TeamOutlined', `type`=1, `redirect`='/im/people/user/index', `component`='ParentLayout', `always_show`=1, `hidden`=0, `status`=1, `level`=2, `tree`=CONCAT('tr_', @imRootId, ' '), `sort`=10, `updated_at`=@now WHERE `id`=@peopleId; UPDATE `hg_admin_menu` SET `pid`=@imRootId, `title`='内容审核', `path`='content', `icon`='FileSearchOutlined', `type`=1, `redirect`='/im/content/private-message/index', `component`='ParentLayout', `always_show`=1, `hidden`=0, `status`=1, `level`=2, `tree`=CONCAT('tr_', @imRootId, ' '), `sort`=20, `updated_at`=@now WHERE `id`=@contentId; UPDATE `hg_admin_menu` SET `pid`=@imRootId, `title`='日志审计', `path`='audit', `icon`='AuditOutlined', `type`=1, `redirect`='/im/audit/operation/index', `component`='ParentLayout', `always_show`=1, `hidden`=0, `status`=1, `level`=2, `tree`=CONCAT('tr_', @imRootId, ' '), `sort`=30, `updated_at`=@now WHERE `id`=@auditId; UPDATE `hg_admin_menu` SET `pid`=@imRootId, `title`='平台设置', `path`='settings', `icon`='SettingOutlined', `type`=1, `redirect`='/im/settings/tenant/index', `component`='ParentLayout', `always_show`=1, `hidden`=0, `status`=1, `level`=2, `tree`=CONCAT('tr_', @imRootId, ' '), `sort`=40, `updated_at`=@now WHERE `id`=@settingsId; UPDATE `hg_admin_menu` SET `pid`=@imRootId, `icon`='DashboardOutlined', `type`=2, `level`=2, `tree`=CONCAT('tr_', @imRootId, ' '), `sort`=5, `updated_at`=@now WHERE `name`='imDashboardIndex'; UPDATE `hg_admin_menu` SET `redirect`='/im/dashboard/index', `updated_at`=@now WHERE `id`=@imRootId; -- User and group management. UPDATE `hg_admin_menu` SET `pid`=@peopleId, `title`='用户管理', `path`='user/index', `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @peopleId, ' '), `sort`=10, `updated_at`=@now WHERE `name`='imUserIndex'; UPDATE `hg_admin_menu` SET `pid`=@peopleId, `path`='user-policy-group/index', `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @peopleId, ' '), `sort`=20, `updated_at`=@now WHERE `name`='imUserPolicyGroupIndex'; UPDATE `hg_admin_menu` SET `pid`=@peopleId, `title`='群组管理', `path`='group/index', `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @peopleId, ' '), `sort`=30, `updated_at`=@now WHERE `name`='imGroupIndex'; UPDATE `hg_admin_menu` SET `pid`=@peopleId, `title`='邀请码管理', `path`='registration-invite/index', `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @peopleId, ' '), `sort`=50, `updated_at`=@now WHERE `name`='imRegistrationInviteIndex'; -- Content review. UPDATE `hg_admin_menu` SET `pid`=@contentId, `path`='private-message/index', `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @contentId, ' '), `sort`=10, `updated_at`=@now WHERE `name`='imPrivateMessageIndex'; UPDATE `hg_admin_menu` SET `pid`=@contentId, `path`='group-message/index', `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @contentId, ' '), `sort`=20, `updated_at`=@now WHERE `name`='imGroupMessageIndex'; UPDATE `hg_admin_menu` SET `pid`=@contentId, `path`='sensitive-word/index', `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @contentId, ' '), `sort`=30, `updated_at`=@now WHERE `name`='imSensitiveWordIndex'; UPDATE `hg_admin_menu` SET `pid`=@contentId, `title`='文件管理', `path`='file/index', `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @contentId, ' '), `sort`=40, `updated_at`=@now WHERE `name`='imFileIndex'; UPDATE `hg_admin_menu` SET `pid`=@contentId, `title`='用户反馈', `path`='feedback/index', `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @contentId, ' '), `sort`=50, `updated_at`=@now WHERE `name`='imWorkOrderIndex'; UPDATE `hg_admin_menu` SET `pid`=@contentId, `title`='实名审核', `path`='realname/index', `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @contentId, ' '), `sort`=60, `updated_at`=@now WHERE `name`='imRealnameIndex'; UPDATE `hg_admin_menu` SET `pid`=@contentId, `path`='abuse-reason/index', `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @contentId, ' '), `sort`=70, `updated_at`=@now WHERE `name`='imAbuseReasonIndex'; -- Logs, audit and operations. UPDATE `hg_admin_menu` SET `pid`=@auditId, `title`='操作日志', `path`='operation/index', `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @auditId, ' '), `sort`=10, `updated_at`=@now WHERE `name`='imAuditLogIndex'; UPDATE `hg_admin_menu` SET `pid`=@auditId, `title`='用户登录', `path`='user-login/index', `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @auditId, ' '), `sort`=20, `updated_at`=@now WHERE `name`='imUserLoginHistoryIndex'; UPDATE `hg_admin_menu` SET `pid`=@auditId, `path`='login-failure/index', `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @auditId, ' '), `sort`=30, `updated_at`=@now WHERE `name`='imLoginFailureLogIndex'; UPDATE `hg_admin_menu` SET `pid`=@auditId, `path`='kafka-audit/index', `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @auditId, ' '), `sort`=40, `updated_at`=@now WHERE `name`='imKafkaAuditIndex'; UPDATE `hg_admin_menu` SET `pid`=@auditId, `title`='事件队列', `path`='outbox/index', `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @auditId, ' '), `sort`=50, `updated_at`=@now WHERE `name`='imOutboxIndex'; UPDATE `hg_admin_menu` SET `pid`=@auditId, `path`='kafka-command/index', `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @auditId, ' '), `sort`=60, `updated_at`=@now WHERE `name`='imKafkaCommandIndex'; UPDATE `hg_admin_menu` SET `pid`=@auditId, `path`='dead-letter/index', `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @auditId, ' '), `sort`=70, `updated_at`=@now WHERE `name`='imDeadLetterIndex'; UPDATE `hg_admin_menu` SET `pid`=@auditId, `path`='task-dashboard/index', `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @auditId, ' '), `sort`=80, `updated_at`=@now WHERE `name`='imTaskDashboardIndex'; -- System and tenant settings. UPDATE `hg_admin_menu` SET `pid`=@settingsId, `title`='商户管理', `path`='tenant/index', `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @settingsId, ' '), `sort`=10, `updated_at`=@now WHERE `name`='imTenantIndex'; UPDATE `hg_admin_menu` SET `pid`=@settingsId, `title`='IP黑白名单', `path`='security-policy/index', `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @settingsId, ' '), `sort`=20, `updated_at`=@now WHERE `name`='imSecurityPolicyIndex'; UPDATE `hg_admin_menu` SET `pid`=@settingsId, `path`='file-policy/index', `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @settingsId, ' '), `sort`=30, `updated_at`=@now WHERE `name`='imFilePolicyIndex'; UPDATE `hg_admin_menu` SET `pid`=@settingsId, `path`='external-config/index', `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @settingsId, ' '), `sort`=50, `updated_at`=@now WHERE `name`='imExternalConfigIndex'; UPDATE `hg_admin_menu` SET `pid`=@settingsId, `path`='notification/index', `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @settingsId, ' '), `sort`=60, `updated_at`=@now WHERE `name`='imNotificationIndex'; UPDATE `hg_admin_menu` SET `pid`=@settingsId, `path`='app-release/index', `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @settingsId, ' '), `sort`=70, `updated_at`=@now WHERE `name`='imAppReleaseIndex'; -- Policy version page: flattened strategy form moved out of the (now IP-focused) security policy page. INSERT INTO `hg_admin_menu` (`pid`,`title`,`name`,`path`,`icon`,`type`,`redirect`,`permissions`,`permission_name`,`component`,`always_show`,`active_menu`,`is_root`,`is_frame`,`frame_src`,`keep_alive`,`hidden`,`affix`,`level`,`tree`,`sort`,`remark`,`status`,`created_at`,`updated_at`) SELECT @settingsId,'安全策略','imPolicyVersionIndex','policy-version/index','','2','','/imSecurityPolicy/list','','/imPolicyVersion/index','1','imManager','0','0','','0','0','0','3',CONCAT('tr_', @imRootId, ' tr_', @settingsId, ' '),'25','','1',@now,@now WHERE @settingsId IS NOT NULL AND NOT EXISTS (SELECT 1 FROM `hg_admin_menu` WHERE `name` = 'imPolicyVersionIndex'); SET @policyVersionId := (SELECT `id` FROM `hg_admin_menu` WHERE `name` = 'imPolicyVersionIndex' LIMIT 1); UPDATE `hg_admin_menu` SET `pid`=@settingsId, `title`='安全策略', `path`='policy-version/index', `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @settingsId, ' '), `sort`=25, `updated_at`=@now WHERE `id`=@policyVersionId; -- Move policy buttons from the security policy page to the policy version page. UPDATE `hg_admin_menu` SET `pid`=@policyVersionId, `updated_at`=@now WHERE `name` IN ('imSecurityPolicyView','imSecurityPolicySave','imSecurityPolicyPublish','imSecurityPolicyRestoreDefault','imSecurityPolicyLoginLockoutConfig'); -- Deprecate the publish button: policy save takes effect immediately (single-record model). UPDATE `hg_admin_menu` SET `status`=2, `hidden`=1, `updated_at`=@now WHERE `name`='imSecurityPolicyPublish'; DELETE FROM `hg_admin_role_menu` WHERE `menu_id` IN (SELECT `id` FROM `hg_admin_menu` WHERE `name`='imSecurityPolicyPublish'); -- Grant the policy version page to roles that already own any migrated policy button. INSERT INTO `hg_admin_role_menu` (`role_id`, `menu_id`) SELECT DISTINCT rm.`role_id`, @policyVersionId FROM `hg_admin_role_menu` rm JOIN `hg_admin_menu` btn ON btn.`id` = rm.`menu_id` LEFT JOIN `hg_admin_role_menu` existing ON existing.`role_id` = rm.`role_id` AND existing.`menu_id` = @policyVersionId WHERE btn.`name` IN ('imSecurityPolicyView','imSecurityPolicySave','imSecurityPolicyPublish','imSecurityPolicyRestoreDefault','imSecurityPolicyLoginLockoutConfig') AND existing.`menu_id` IS NULL; INSERT INTO `hg_admin_menu` (`pid`, `title`, `name`, `path`, `icon`, `type`, `redirect`, `permissions`, `permission_name`, `component`, `always_show`, `active_menu`, `is_root`, `is_frame`, `frame_src`, `keep_alive`, `hidden`, `affix`, `level`, `tree`, `sort`, `remark`, `status`, `created_at`, `updated_at`) SELECT @settingsId, '企业注册', 'imTenantApplicationIndex', 'tenant-application/index', '', 2, '', '/imTenantApplication/list', '', '/imTenantApplication/index', 1, 'imSystemSettings', 0, 0, '', 0, 0, 0, 3, CONCAT('tr_', @imRootId, ' tr_', @settingsId, ' '), 80, '', 1, @now, @now WHERE @settingsId IS NOT NULL AND NOT EXISTS (SELECT 1 FROM `hg_admin_menu` WHERE `name`='imTenantApplicationIndex'); INSERT INTO `hg_admin_menu` (`pid`, `title`, `name`, `path`, `icon`, `type`, `redirect`, `permissions`, `permission_name`, `component`, `always_show`, `active_menu`, `is_root`, `is_frame`, `frame_src`, `keep_alive`, `hidden`, `affix`, `level`, `tree`, `sort`, `remark`, `status`, `created_at`, `updated_at`) SELECT @settingsId, '企业反馈', 'imTenantEntryFeedbackIndex', 'tenant-entry-feedback/index', '', 2, '', '/imTenantEntryFeedback/list', '', '/imTenantEntryFeedback/index', 1, 'imSystemSettings', 0, 0, '', 0, 0, 0, 3, CONCAT('tr_', @imRootId, ' tr_', @settingsId, ' '), 90, '', 1, @now, @now WHERE @settingsId IS NOT NULL AND NOT EXISTS (SELECT 1 FROM `hg_admin_menu` WHERE `name`='imTenantEntryFeedbackIndex'); SET @tenantApplicationId := (SELECT `id` FROM `hg_admin_menu` WHERE `name`='imTenantApplicationIndex' LIMIT 1); SET @tenantEntryFeedbackId := (SELECT `id` FROM `hg_admin_menu` WHERE `name`='imTenantEntryFeedbackIndex' LIMIT 1); UPDATE `hg_admin_menu` SET `pid`=@settingsId, `title`='企业注册', `path`='tenant-application/index', `permissions`='/imTenantApplication/list', `component`='/imTenantApplication/index', `active_menu`='imSystemSettings', `type`=2, `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @settingsId, ' '), `sort`=80, `hidden`=0, `status`=1, `updated_at`=@now WHERE `id`=@tenantApplicationId; UPDATE `hg_admin_menu` SET `pid`=@settingsId, `title`='企业反馈', `path`='tenant-entry-feedback/index', `permissions`='/imTenantEntryFeedback/list', `component`='/imTenantEntryFeedback/index', `active_menu`='imSystemSettings', `type`=2, `level`=3, `tree`=CONCAT('tr_', @imRootId, ' tr_', @settingsId, ' '), `sort`=90, `hidden`=0, `status`=1, `updated_at`=@now WHERE `id`=@tenantEntryFeedbackId; INSERT INTO `hg_admin_menu` (`pid`, `title`, `name`, `path`, `icon`, `type`, `redirect`, `permissions`, `permission_name`, `component`, `always_show`, `active_menu`, `is_root`, `is_frame`, `frame_src`, `keep_alive`, `hidden`, `affix`, `level`, `tree`, `sort`, `remark`, `status`, `created_at`, `updated_at`) SELECT @tenantApplicationId, '企业注册详情', 'imTenantApplicationView', '', '', 3, '', '/imTenantApplication/view', '', '', 1, '', 0, 0, '', 0, 1, 0, 4, CONCAT('tr_', @imRootId, ' tr_', @settingsId, ' tr_', @tenantApplicationId, ' '), 10, '', 1, @now, @now WHERE @tenantApplicationId IS NOT NULL AND NOT EXISTS (SELECT 1 FROM `hg_admin_menu` WHERE `name`='imTenantApplicationView'); INSERT INTO `hg_admin_menu` (`pid`, `title`, `name`, `path`, `icon`, `type`, `redirect`, `permissions`, `permission_name`, `component`, `always_show`, `active_menu`, `is_root`, `is_frame`, `frame_src`, `keep_alive`, `hidden`, `affix`, `level`, `tree`, `sort`, `remark`, `status`, `created_at`, `updated_at`) SELECT @tenantEntryFeedbackId, '企业反馈详情', 'imTenantEntryFeedbackView', '', '', 3, '', '/imTenantEntryFeedback/view', '', '', 1, '', 0, 0, '', 0, 1, 0, 4, CONCAT('tr_', @imRootId, ' tr_', @settingsId, ' tr_', @tenantEntryFeedbackId, ' '), 10, '', 1, @now, @now WHERE @tenantEntryFeedbackId IS NOT NULL AND NOT EXISTS (SELECT 1 FROM `hg_admin_menu` WHERE `name`='imTenantEntryFeedbackView'); UPDATE `hg_admin_menu` SET `pid`=@tenantApplicationId, `title`='企业注册详情', `permissions`='/imTenantApplication/view', `type`=3, `level`=4, `tree`=CONCAT('tr_', @imRootId, ' tr_', @settingsId, ' tr_', @tenantApplicationId, ' '), `hidden`=1, `status`=1, `updated_at`=@now WHERE `name`='imTenantApplicationView'; UPDATE `hg_admin_menu` SET `pid`=@tenantEntryFeedbackId, `title`='企业反馈详情', `permissions`='/imTenantEntryFeedback/view', `type`=3, `level`=4, `tree`=CONCAT('tr_', @imRootId, ' tr_', @settingsId, ' tr_', @tenantEntryFeedbackId, ' '), `hidden`=1, `status`=1, `updated_at`=@now WHERE `name`='imTenantEntryFeedbackView'; INSERT INTO `hg_admin_role_menu` (`role_id`, `menu_id`) SELECT DISTINCT rm.`role_id`, menu.`id` FROM `hg_admin_role_menu` rm JOIN `hg_admin_menu` menu ON menu.`name` IN ('imTenantApplicationIndex', 'imTenantApplicationView', 'imTenantEntryFeedbackIndex', 'imTenantEntryFeedbackView') LEFT JOIN `hg_admin_role_menu` existing ON existing.`role_id`=rm.`role_id` AND existing.`menu_id`=menu.`id` WHERE rm.`menu_id`=@settingsId AND existing.`menu_id` IS NULL; -- Remove one-page wrapper directories after their page has been moved. UPDATE `hg_admin_menu` SET `status`=2, `hidden`=1, `updated_at`=@now WHERE `name` IN ('imUser', 'imGroup', 'imTenant', 'imRealname', 'imWorkOrder', 'imAuditLog', 'imOutbox'); -- Rebuild button ancestry beneath the moved pages. UPDATE `hg_admin_menu` child JOIN `hg_admin_menu` page ON page.`id` = child.`pid` SET child.`level` = page.`level` + 1, child.`tree` = CONCAT(page.`tree`, 'tr_', page.`id`, ' '), child.`updated_at` = @now WHERE (page.`pid` IN (@peopleId, @contentId, @auditId, @settingsId) OR page.`id` = @policyVersionId) AND child.`type` = 3; -- Give roles that already own pages in a section access to the new directory. INSERT INTO `hg_admin_role_menu` (`role_id`, `menu_id`) SELECT DISTINCT rm.`role_id`, section.`id` FROM `hg_admin_role_menu` rm JOIN `hg_admin_menu` page ON page.`id` = rm.`menu_id` JOIN `hg_admin_menu` section ON section.`id` = page.`pid` LEFT JOIN `hg_admin_role_menu` existing ON existing.`role_id` = rm.`role_id` AND existing.`menu_id` = section.`id` WHERE section.`id` IN (@peopleId, @contentId, @auditId, @settingsId) AND existing.`menu_id` IS NULL; -- Optional features use their own top-level menu and can be replaced independently. INSERT INTO `hg_admin_menu` (`pid`, `title`, `name`, `path`, `icon`, `type`, `redirect`, `permissions`, `permission_name`, `component`, `always_show`, `active_menu`, `is_root`, `is_frame`, `frame_src`, `keep_alive`, `hidden`, `affix`, `level`, `tree`, `sort`, `remark`, `status`, `created_at`, `updated_at`) SELECT 0, '工作台管理', 'workbenchManager', '/workbench', 'AppstoreOutlined', 1, '/workbench/config/index', '', '', 'LAYOUT', 1, '', 1, 0, '', 0, 0, 0, 1, '', 126, '附加功能独立管理入口', 1, @now, @now WHERE NOT EXISTS (SELECT 1 FROM `hg_admin_menu` WHERE `name` = 'workbenchManager'); SET @workbenchRootId := (SELECT `id` FROM `hg_admin_menu` WHERE `name` = 'workbenchManager' LIMIT 1); SET @workbenchId := (SELECT `id` FROM `hg_admin_menu` WHERE `name` = 'imWorkbenchIndex' LIMIT 1); SET @orgId := (SELECT `id` FROM `hg_admin_menu` WHERE `name` = 'imOrgIndex' LIMIT 1); SET @mailboxConfigId := (SELECT `id` FROM `hg_admin_menu` WHERE `name` = 'imMailboxConfigIndex' LIMIT 1); SET @feedbackConfigId := (SELECT `id` FROM `hg_admin_menu` WHERE `name` = 'imFeedbackConfigIndex' LIMIT 1); UPDATE `hg_admin_menu` SET `pid`=0, `title`='工作台管理', `path`='/workbench', `icon`='AppstoreOutlined', `type`=1, `redirect`='/workbench/config/index', `component`='LAYOUT', `always_show`=1, `active_menu`='', `is_root`=1, `hidden`=0, `level`=1, `tree`=CONCAT('tr_', `id`, ' '), `sort`=126, `status`=1, `updated_at`=@now WHERE `id`=@workbenchRootId; UPDATE `hg_admin_menu` SET `pid`=@workbenchRootId, `title`='工作台配置', `path`='config/index', `active_menu`='workbenchManager', `level`=2, `tree`=CONCAT('tr_', @workbenchRootId, ' '), `sort`=10, `status`=1, `hidden`=0, `updated_at`=@now WHERE `id`=@workbenchId; UPDATE `hg_admin_menu` SET `pid`=@workbenchRootId, `title`='组织架构', `path`='org/index', `active_menu`='workbenchManager', `level`=2, `tree`=CONCAT('tr_', @workbenchRootId, ' '), `sort`=20, `status`=1, `hidden`=0, `updated_at`=@now WHERE `id`=@orgId; UPDATE `hg_admin_menu` SET `pid`=@workbenchRootId, `path`='mailbox-config/index', `active_menu`='workbenchManager', `level`=2, `tree`=CONCAT('tr_', @workbenchRootId, ' '), `sort`=30, `status`=1, `hidden`=0, `updated_at`=@now WHERE `id`=@mailboxConfigId; UPDATE `hg_admin_menu` SET `pid`=@workbenchRootId, `path`='feedback-config/index', `active_menu`='workbenchManager', `level`=2, `tree`=CONCAT('tr_', @workbenchRootId, ' '), `sort`=40, `status`=1, `hidden`=0, `updated_at`=@now WHERE `id`=@feedbackConfigId; UPDATE `hg_admin_menu` SET `level`=3, `tree`=CONCAT('tr_', @workbenchRootId, ' tr_', @workbenchId, ' '), `updated_at`=@now WHERE `pid`=@workbenchId AND `type`=3; UPDATE `hg_admin_menu` child JOIN `hg_admin_menu` page ON page.`id`=child.`pid` SET child.`level`=3, child.`tree`=CONCAT('tr_', @workbenchRootId, ' tr_', page.`id`, ' '), child.`updated_at`=@now WHERE page.`id` IN (@orgId, @mailboxConfigId, @feedbackConfigId) AND child.`type`=3; INSERT IGNORE INTO `hg_admin_role_menu` (`role_id`, `menu_id`) SELECT `role_id`, @workbenchRootId FROM `hg_admin_role_menu` WHERE `menu_id` IN (@workbenchId, @orgId, @mailboxConfigId, @feedbackConfigId);