USE youlai_admin;

-- 开放 API 审核菜单初始化
-- 说明：
-- 1. 在“代理平台”下新增“开放API审核”菜单。
-- 2. 用于审核会员开放 API 申请，并授予管理员默认访问权限。

INSERT INTO `sys_menu`
(`id`, `parent_id`, `tree_path`, `name`, `type`, `route_name`, `route_path`, `component`, `perm`,
 `always_show`, `keep_alive`, `visible`, `sort`, `icon`, `redirect`, `create_time`, `update_time`, `params`)
VALUES
(1220, 1100, '0,1100', '开放API审核', 'C', NULL, '/open-api-manage', 'Layout', NULL,
 1, 0, 1, 13, 'api', '/open-api-manage/open-api', NOW(), NOW(), NULL),
(1221, 1220, '0,1100,1220', '开放API申请审核', 'M', 'ProxyOpenApiApply', 'open-api', 'proxy/open-api/index', NULL,
 0, 1, 1, 1, 'form', NULL, NOW(), NOW(), NULL),
(122101, 1221, '0,1100,1220,1221', '开放API申请查询', 'B', NULL, '', NULL, 'openapi:apply:list',
 NULL, NULL, 1, 1, '', NULL, NOW(), NOW(), NULL),
(122102, 1221, '0,1100,1220,1221', '开放API申请审核', 'B', NULL, '', NULL, 'openapi:apply:audit',
 NULL, NULL, 1, 2, '', NULL, NOW(), NOW(), NULL),
(1222, 1220, '0,1100,1220', '开放API回调日志', 'M', 'ProxyOpenApiCallback', 'open-api-callback', 'proxy/open-api-callback/index', NULL,
 0, 1, 1, 2, 'notification', NULL, NOW(), NOW(), NULL),
(122201, 1222, '0,1100,1220,1222', '开放API回调日志查询', 'B', NULL, '', NULL, 'openapi:callback-log:list',
 NULL, NULL, 1, 1, '', NULL, NOW(), NOW(), NULL),
(122202, 1222, '0,1100,1220,1222', '开放API回调日志重发', 'B', NULL, '', NULL, 'openapi:callback-log:retry',
 NULL, NULL, 1, 2, '', NULL, NOW(), NOW(), NULL),
(1223, 1220, '0,1100,1220', '开放API账户中心', 'M', 'ProxyOpenApiAccount', 'open-api-account', 'proxy/open-api-account/index', NULL,
 0, 1, 0, 3, 'wallet', NULL, NOW(), NOW(), NULL)
ON DUPLICATE KEY UPDATE
`name` = VALUES(`name`),
`route_name` = VALUES(`route_name`),
`route_path` = VALUES(`route_path`),
`component` = VALUES(`component`),
`perm` = VALUES(`perm`),
`keep_alive` = VALUES(`keep_alive`),
`visible` = VALUES(`visible`),
`sort` = VALUES(`sort`),
`icon` = VALUES(`icon`),
`update_time` = NOW();

INSERT IGNORE INTO `sys_role_menu` (`role_id`, `menu_id`) VALUES
(2, 1220), (2, 1221), (2, 122101), (2, 122102), (2, 1222), (2, 122201), (2, 122202), (2, 1223);
