-- 完整修复所有角色的菜单配置
-- 确保菜单名称格式正确（父菜单用连字符，子菜单用下划线）

-- 1. 修复 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,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';

-- 2. 修复 R_ADMIN（管理员）- 设备管理、大屏、用户管理、申请管理
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';

-- 3. 修复 R_USER（普通用户）- 我的设备、我的申请
UPDATE sys_role 
SET menus = '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_USER';

-- 4. 修复 R_STU（学生）- 我的设备状态、我的申请列表
UPDATE sys_role 
SET menus = 'my-device,my-device_status,my-application,my-application_my-list'
WHERE role_code = 'R_STU';

-- 验证修复结果
SELECT 
    role_code AS '角色代码',
    role_name AS '角色名称',
    menus AS '菜单配置',
    status AS '状态'
FROM sys_role 
WHERE status = 1
ORDER BY 
    CASE role_code
        WHEN 'R_SUPER' THEN 1
        WHEN 'R_ADMIN' THEN 2
        WHEN 'R_USER' THEN 3
        WHEN 'R_STU' THEN 4
        ELSE 5
    END;
