-- ========================================
-- 执行此 SQL 脚本来修复组件路径问题
-- ========================================
-- 问题说明：
-- 1. 路由名称(name)使用下划线：user_manage, my_device
-- 2. 但组件路径(component)必须使用连字符匹配实际文件夹：user-manage, my-device
-- 3. 之前的路由名称修复导致 component 路径不匹配，引发前端错误
-- ========================================

USE soybean_admin;

-- 修复 user-manage 相关组件（文件夹是 user-manage）
UPDATE sys_route SET component = 'layout.base$view.user-manage' WHERE name = 'user_manage';
UPDATE sys_route SET component = 'layout.base$view.user-manage_list' WHERE name = 'user_manage_list';
UPDATE sys_route SET component = 'layout.base$view.user-manage_role' WHERE name = 'user_manage_role';
UPDATE sys_route SET component = 'layout.base$view.user-manage_permission' WHERE name = 'user_manage_permission';

-- 修复 my-device 相关组件（文件夹是 my-device）
UPDATE sys_route SET component = 'layout.base$view.my-device' WHERE name = 'my_device';
UPDATE sys_route SET component = 'layout.base$view.my-device_status' WHERE name = 'my_device_status';
UPDATE sys_route SET component = 'layout.base$view.my-device_power-control' WHERE name = 'my_device_power';
UPDATE sys_route SET component = 'layout.base$view.my-device_remote-control' WHERE name = 'my_device_remote';

-- 修复 my-application 相关组件（文件夹是 my-application）
UPDATE sys_route SET component = 'layout.base$view.my-application' WHERE name = 'my_application';
UPDATE sys_route SET component = 'layout.base$view.my-application_apply' WHERE name = 'my_application_apply';
UPDATE sys_route SET component = 'layout.base$view.my-application_my-list' WHERE name = 'my_application_list';

-- 验证修复结果
SELECT 
    name AS '路由名称(下划线)', 
    path AS '路径', 
    component AS '组件路径(连字符)' 
FROM sys_route 
WHERE name LIKE '%user%' OR name LIKE '%my_%' 
ORDER BY name;

-- 预期结果示例：
-- user_manage      | /user-manage            | layout.base$view.user-manage
-- user_manage_list | /user-manage/list       | layout.base$view.user-manage_list
-- my_device        | /my-device              | layout.base$view.my-device
-- my_device_status | /my-device/status       | layout.base$view.my-device_status
