USE youlai_admin;

-- 代理平台主管演示角色
SET @proxy_role_code = 'PROXY_MANAGER';

INSERT INTO `sys_role`
(`name`, `code`, `sort`, `status`, `data_scope`, `create_by`, `create_time`, `update_by`, `update_time`, `is_deleted`)
SELECT '代理平台主管', @proxy_role_code, 80, 1, 1, 1, now(), 1, now(), 0
FROM DUAL
WHERE NOT EXISTS (
    SELECT 1
    FROM `sys_role`
    WHERE `code` = @proxy_role_code
);

SET @proxy_role_id = (
    SELECT `id`
    FROM `sys_role`
    WHERE `code` = @proxy_role_code
    LIMIT 1
);

INSERT IGNORE INTO `sys_role_menu` (`role_id`, `menu_id`)
SELECT @proxy_role_id, `id`
FROM `sys_menu`
WHERE `id` IN (
    1100,
    1110, 11101, 11102, 11103, 11104,
    1120, 11201, 11202, 11203, 11204,
    1130, 11301, 11302, 11303, 11304,
    1140, 11401, 11402, 11403, 11404,
    1150, 11501, 11502, 11503,
    1160, 11601, 11602, 11603,
    1170, 11701, 11702,
    1180, 11801, 11802, 11803, 11804,
    1190, 11901, 11902,
    1200, 12001, 12002, 12003
);
