INSERT INTO platform_permission (id, permission_code, permission_name, module)
VALUES
    (8, 'platform.expert.read', '平台专家查看', 'platform'),
    (9, 'platform.expert.manage', '平台专家管理', 'platform')
ON DUPLICATE KEY UPDATE permission_name = VALUES(permission_name), module = VALUES(module);

INSERT INTO platform_role_permission (id, role_id, permission_id)
VALUES
    (8, 1, 8),
    (9, 1, 9)
ON DUPLICATE KEY UPDATE permission_id = VALUES(permission_id);

INSERT INTO platform_menu (id, menu_code, menu_name, route_path, permission_code, sort_no, status, is_deleted, created_by, updated_by)
VALUES
    (7, 'platform_expert', '专家管理', '/platform/experts', 'platform.expert.read', 18, 'ENABLED', 0, 0, 0)
ON DUPLICATE KEY UPDATE
    menu_name = VALUES(menu_name),
    route_path = VALUES(route_path),
    permission_code = VALUES(permission_code),
    sort_no = VALUES(sort_no),
    status = VALUES(status),
    is_deleted = VALUES(is_deleted),
    updated_at = CURRENT_TIMESTAMP;

INSERT INTO platform_role_menu (id, role_id, menu_id)
VALUES
    (7, 1, 7)
ON DUPLICATE KEY UPDATE menu_id = VALUES(menu_id);

UPDATE menu
SET status='DISABLED', is_deleted=1, updated_at=CURRENT_TIMESTAMP
WHERE tenant_id=1 AND route_path IN ('/audit-logs', '/experts');
