-- ============================================================
-- 【手动清理+插入】重点关注人员管理菜单数据
-- 使用场景：数据库已有脏数据需要清除重新插入时执行
-- 执行顺序：先执行 DELTE，再执行 INSERT
-- ============================================================

-- Step 1: 清除旧数据（包括角色授权和菜单记录）
DELETE FROM sys_role_permission WHERE permission_id in ('178060100000002','178060100000010','178060100000011','178060100000012','178060100000013','178060100000014','178060100000015','178060100000016');
DELETE FROM sys_permission WHERE id in ('178060100000002','178060100000010','178060100000011','178060100000012','178060100000013','178060100000014','178060100000015','178060100000016');

-- Step 2: 插入新数据
-- 一级菜单：信息智能匹配推送
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
VALUES ('178060100000002', '', '信息智能匹配推送', '/focusPersonnel', 'layouts/default/index', 1, NULL, '/focusPersonnel/focusPersonnelList', 0, NULL, '1', 1.80, 0, 'ant-design:audit-outlined', 0, 0, 0, 0, NULL, 'admin', '2026-06-03 10:00:00', NULL, NULL, 0, 0, '1', 0);

-- 二级菜单：重点关注人员管理
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
VALUES ('178060100000010', '178060100000002', '重点关注人员管理', '/focusPersonnel/focusPersonnelList', 'focuspersonnel/FocusPersonnelList', 1, NULL, NULL, 1, NULL, '1', 1.00, 0, 'ant-design:user-outlined', 1, 0, 0, 0, NULL, 'admin', '2026-06-03 10:00:00', NULL, NULL, 0, 0, '1', 0);

-- 按钮权限
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) VALUES ('178060100000011', '178060100000010', '添加重点关注人员管理', NULL, NULL, 0, NULL, NULL, 2, 'focus_personnel:add', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-06-03 10:00:00', NULL, NULL, 0, 0, '1', 0);
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) VALUES ('178060100000012', '178060100000010', '编辑重点关注人员管理', NULL, NULL, 0, NULL, NULL, 2, 'focus_personnel:edit', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-06-03 10:00:00', NULL, NULL, 0, 0, '1', 0);
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) VALUES ('178060100000013', '178060100000010', '删除重点关注人员管理', NULL, NULL, 0, NULL, NULL, 2, 'focus_personnel:delete', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-06-03 10:00:00', NULL, NULL, 0, 0, '1', 0);
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) VALUES ('178060100000014', '178060100000010', '批量删除重点关注人员管理', NULL, NULL, 0, NULL, NULL, 2, 'focus_personnel:deleteBatch', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-06-03 10:00:00', NULL, NULL, 0, 0, '1', 0);
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) VALUES ('178060100000015', '178060100000010', '导出excel_重点关注人员管理', NULL, NULL, 0, NULL, NULL, 2, 'focus_personnel:exportXls', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-06-03 10:00:00', NULL, NULL, 0, 0, '1', 0);
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) VALUES ('178060100000016', '178060100000010', '导入excel_重点关注人员管理', NULL, NULL, 0, NULL, NULL, 2, 'focus_personnel:importExcel', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-06-03 10:00:00', NULL, NULL, 0, 0, '1', 0);

-- 角色授权（admin角色，role_id固定值 f6817f48af4fb3af11b9e8bf182f618b）
INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('178060100000021', 'f6817f48af4fb3af11b9e8bf182f618b', '178060100000002', NULL, '2026-06-03 10:00:00', '127.0.0.1');
INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('178060100000022', 'f6817f48af4fb3af11b9e8bf182f618b', '178060100000010', NULL, '2026-06-03 10:00:00', '127.0.0.1');
INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('178060100000023', 'f6817f48af4fb3af11b9e8bf182f618b', '178060100000011', NULL, '2026-06-03 10:00:00', '127.0.0.1');
INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('178060100000024', 'f6817f48af4fb3af11b9e8bf182f618b', '178060100000012', NULL, '2026-06-03 10:00:00', '127.0.0.1');
INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('178060100000025', 'f6817f48af4fb3af11b9e8bf182f618b', '178060100000013', NULL, '2026-06-03 10:00:00', '127.0.0.1');
INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('178060100000026', 'f6817f48af4fb3af11b9e8bf182f618b', '178060100000014', NULL, '2026-06-03 10:00:00', '127.0.0.1');
INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('178060100000027', 'f6817f48af4fb3af11b9e8bf182f618b', '178060100000015', NULL, '2026-06-03 10:00:00', '127.0.0.1');
INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('178060100000028', 'f6817f48af4fb3af11b9e8bf182f618b', '178060100000016', NULL, '2026-06-03 10:00:00', '127.0.0.1');

-- Step 3: 验证结果
SELECT 'sys_permission' as tbl, id, parent_id, name, component, menu_type, always_show, redirect, is_leaf, status, del_flag
FROM sys_permission WHERE id like '1780601000000%'
UNION ALL
SELECT 'sys_role_permission' as tbl, rp.id, rp.permission_id, p.name, '', 0, 0, '', 0, 0, 0
FROM sys_role_permission rp
JOIN sys_permission p ON rp.permission_id = p.id
WHERE rp.permission_id like '1780601000000%'
ORDER BY tbl, id;