-- 最终修复用户管理路由的名称和组件
USE soybean_admin;

-- 1. 修复路由名称（必须与前端 routeMap 一致）
UPDATE sys_route SET name = 'user-manage' WHERE route_id = 'user_manage';
UPDATE sys_route SET name = 'user-manage_list' WHERE route_id = 'user_list';
UPDATE sys_route SET name = 'user-manage_role' WHERE route_id = 'user_role';
UPDATE sys_route SET name = 'user-manage_permission' WHERE route_id = 'user_permission';

-- 2. 修复组件路径
UPDATE sys_route SET component = 'layout.base' WHERE route_id = 'user_manage';
UPDATE sys_route SET component = 'view.user-manage_list' WHERE route_id = 'user_list';
UPDATE sys_route SET component = 'view.user-manage_role' WHERE route_id = 'user_role';
UPDATE sys_route SET component = 'view.user-manage_permission' WHERE route_id = 'user_permission';

-- 3. 更新角色菜单配置（使用新的路由名称）
UPDATE sys_role 
SET menus = 'device,device_list,device_group,device_monitor,device_online,device_power,screen,screen_wall,screen_control,screen_record,user-manage,user-manage_list,user-manage_role,user-manage_permission,application,application_approval,application_history,system,system_agent,system_amt,system_log,my-device,my-device_status,my-device_remote-control,my-device_power-control,my-application,my-application_apply,my-application_my-list'
WHERE role_code = 'R_SUPER';

UPDATE sys_role 
SET menus = 'device,device_list,device_group,device_monitor,device_online,device_power,screen,screen_wall,screen_control,screen_record,user-manage,user-manage_list,user-manage_role,application,application_approval,application_history'
WHERE role_code = 'R_ADMIN';

-- 4. 验证修改结果
SELECT '=== 用户管理路由配置 ===' AS info;
SELECT route_id, name, path, component 
FROM sys_route 
WHERE route_id IN ('user_manage', 'user_list', 'user_role', 'user_permission')
ORDER BY order_num;

SELECT '' AS '';
SELECT '=== 角色菜单配置（应包含 user-manage 相关）===' AS info;
SELECT role_code, role_name, 
       SUBSTRING(menus, 1, 100) AS menus_preview
FROM sys_role 
WHERE role_code IN ('R_SUPER', 'R_ADMIN');
