-- 更新桌面管理菜单结构
-- 将原来的"远程桌面"改为"系统添加"和"系统管理"两个子菜单

-- 1. 更新原有的菜单项（ID=21）为"系统添加"
UPDATE Menus SET 
    Name = 'OsDevices',
    Path = 'os-devices',
    Component = '/desktop-manage/os-devices',
    Title = '系统添加',
    Sort = 1
WHERE Id = 21;

-- 2. 添加新的"系统管理"菜单项（ID=22）
INSERT INTO Menus (Id, ParentId, Name, Path, Component, Title, Icon, Sort, Roles, IsHide, KeepAlive, IsSystem, IsIframe, IsHideTab, CreatedAt)
VALUES (22, 20, 'DesktopDevices', 'devices', '/desktop-manage/devices', '系统管理', NULL, 2, 'R_SUPER,R_ADMIN', 0, 1, 1, 0, 0, NOW())
ON DUPLICATE KEY UPDATE
    Name = 'DesktopDevices',
    Path = 'devices',
    Component = '/desktop-manage/devices',
    Title = '系统管理',
    Sort = 2;

-- 3. 为超级管理员和管理员角色添加新菜单权限
INSERT IGNORE INTO RoleMenus (RoleId, MenuId)
SELECT r.Id, 22 FROM Roles r WHERE r.RoleCode IN ('R_SUPER', 'R_ADMIN');
