-- ============================================
-- 风控平台菜单权限 SQL 脚本
-- 创建时间: 2026-01-17
-- 依赖: 已存在 sys_menu 表(由 ry_vue_5.X.sql 创建)
-- ============================================

-- 设置变量(用于存储父菜单ID)
SET @risk_parent_id = 0;

-- 1. 一级目录: 风控平台
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, remark)
VALUES ('风控平台', 0, 6, 'risk', NULL, 1, 0, 'M', '0', '0', '', 'warning', 103, 1, NOW(), '风控平台目录');

SET @risk_parent_id = LAST_INSERT_ID();

-- ============================================
-- 2. 安全隐患
-- ============================================
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, remark)
VALUES ('安全隐患', @risk_parent_id, 1, 'hiddenDanger', 'risk/hiddenDanger/index', 1, 0, 'C', '0', '0', 'risk:hiddenDanger:list', '#', 103, 1, NOW(), '安全隐患菜单');

SET @hidden_danger_id = LAST_INSERT_ID();

-- 安全隐患按钮
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, remark) VALUES
('隐患查询', @hidden_danger_id, 1, '#', '', 1, 0, 'F', '0', '0', 'risk:hiddenDanger:query', '#', 103, 1, NOW(), ''),
('隐患新增', @hidden_danger_id, 2, '#', '', 1, 0, 'F', '0', '0', 'risk:hiddenDanger:add', '#', 103, 1, NOW(), ''),
('隐患修改', @hidden_danger_id, 3, '#', '', 1, 0, 'F', '0', '0', 'risk:hiddenDanger:edit', '#', 103, 1, NOW(), ''),
('隐患删除', @hidden_danger_id, 4, '#', '', 1, 0, 'F', '0', '0', 'risk:hiddenDanger:remove', '#', 103, 1, NOW(), ''),
('隐患导出', @hidden_danger_id, 5, '#', '', 1, 0, 'F', '0', '0', 'risk:hiddenDanger:export', '#', 103, 1, NOW(), ''),
('隐患处理', @hidden_danger_id, 6, '#', '', 1, 0, 'F', '0', '0', 'risk:hiddenDanger:handle', '#', 103, 1, NOW(), '');

-- ============================================
-- 3. 危险源上报
-- ============================================
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, remark)
VALUES ('危险源上报', @risk_parent_id, 2, 'dangerSource', 'risk/dangerSource/index', 1, 0, 'C', '0', '0', 'risk:dangerSource:list', '#', 103, 1, NOW(), '危险源上报菜单');

SET @danger_source_id = LAST_INSERT_ID();

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, remark) VALUES
('危险源查询', @danger_source_id, 1, '#', '', 1, 0, 'F', '0', '0', 'risk:dangerSource:query', '#', 103, 1, NOW(), ''),
('危险源新增', @danger_source_id, 2, '#', '', 1, 0, 'F', '0', '0', 'risk:dangerSource:add', '#', 103, 1, NOW(), ''),
('危险源修改', @danger_source_id, 3, '#', '', 1, 0, 'F', '0', '0', 'risk:dangerSource:edit', '#', 103, 1, NOW(), ''),
('危险源删除', @danger_source_id, 4, '#', '', 1, 0, 'F', '0', '0', 'risk:dangerSource:remove', '#', 103, 1, NOW(), ''),
('危险源导出', @danger_source_id, 5, '#', '', 1, 0, 'F', '0', '0', 'risk:dangerSource:export', '#', 103, 1, NOW(), '');

-- ============================================
-- 4. 作业上报
-- ============================================
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, remark)
VALUES ('作业上报', @risk_parent_id, 3, 'workReport', 'risk/workReport/index', 1, 0, 'C', '0', '0', 'risk:workReport:list', '#', 103, 1, NOW(), '作业上报菜单');

SET @work_report_id = LAST_INSERT_ID();

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, remark) VALUES
('作业查询', @work_report_id, 1, '#', '', 1, 0, 'F', '0', '0', 'risk:workReport:query', '#', 103, 1, NOW(), ''),
('作业新增', @work_report_id, 2, '#', '', 1, 0, 'F', '0', '0', 'risk:workReport:add', '#', 103, 1, NOW(), ''),
('作业修改', @work_report_id, 3, '#', '', 1, 0, 'F', '0', '0', 'risk:workReport:edit', '#', 103, 1, NOW(), ''),
('作业删除', @work_report_id, 4, '#', '', 1, 0, 'F', '0', '0', 'risk:workReport:remove', '#', 103, 1, NOW(), ''),
('作业审核', @work_report_id, 5, '#', '', 1, 0, 'F', '0', '0', 'risk:workReport:review', '#', 103, 1, NOW(), ''),
('作业导出', @work_report_id, 6, '#', '', 1, 0, 'F', '0', '0', 'risk:workReport:export', '#', 103, 1, NOW(), '');

-- ============================================
-- 5. 人员信息
-- ============================================
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, remark)
VALUES ('人员信息', @risk_parent_id, 4, 'personnel', 'risk/personnel/index', 1, 0, 'C', '0', '0', 'risk:personnel:list', '#', 103, 1, NOW(), '人员信息菜单');

SET @personnel_id = LAST_INSERT_ID();

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, remark) VALUES
('人员查询', @personnel_id, 1, '#', '', 1, 0, 'F', '0', '0', 'risk:personnel:query', '#', 103, 1, NOW(), ''),
('人员新增', @personnel_id, 2, '#', '', 1, 0, 'F', '0', '0', 'risk:personnel:add', '#', 103, 1, NOW(), ''),
('人员修改', @personnel_id, 3, '#', '', 1, 0, 'F', '0', '0', 'risk:personnel:edit', '#', 103, 1, NOW(), ''),
('人员删除', @personnel_id, 4, '#', '', 1, 0, 'F', '0', '0', 'risk:personnel:remove', '#', 103, 1, NOW(), ''),
('证书查询', @personnel_id, 5, '#', '', 1, 0, 'F', '0', '0', 'risk:personnelCert:list', '#', 103, 1, NOW(), ''),
('证书新增', @personnel_id, 6, '#', '', 1, 0, 'F', '0', '0', 'risk:personnelCert:add', '#', 103, 1, NOW(), ''),
('证书修改', @personnel_id, 7, '#', '', 1, 0, 'F', '0', '0', 'risk:personnelCert:edit', '#', 103, 1, NOW(), ''),
('证书删除', @personnel_id, 8, '#', '', 1, 0, 'F', '0', '0', 'risk:personnelCert:remove', '#', 103, 1, NOW(), '');

-- ============================================
-- 6. 审计工作
-- ============================================
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, remark)
VALUES ('审计工作', @risk_parent_id, 5, 'personnelChange', 'risk/personnelChange/index', 1, 0, 'C', '0', '0', 'risk:personnelChange:list', '#', 103, 1, NOW(), '审计工作菜单');

SET @personnel_change_id = LAST_INSERT_ID();

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, remark) VALUES
('人员变动查询', @personnel_change_id, 1, '#', '', 1, 0, 'F', '0', '0', 'risk:personnelChange:query', '#', 103, 1, NOW(), ''),
('人员变动新增', @personnel_change_id, 2, '#', '', 1, 0, 'F', '0', '0', 'risk:personnelChange:add', '#', 103, 1, NOW(), ''),
('人员变动修改', @personnel_change_id, 3, '#', '', 1, 0, 'F', '0', '0', 'risk:personnelChange:edit', '#', 103, 1, NOW(), ''),
('人员变动删除', @personnel_change_id, 4, '#', '', 1, 0, 'F', '0', '0', 'risk:personnelChange:remove', '#', 103, 1, NOW(), ''),
('审计文件查询', @personnel_change_id, 5, '#', '', 1, 0, 'F', '0', '0', 'risk:auditFile:list', '#', 103, 1, NOW(), ''),
('审计文件上传', @personnel_change_id, 6, '#', '', 1, 0, 'F', '0', '0', 'risk:auditFile:add', '#', 103, 1, NOW(), ''),
('审计文件删除', @personnel_change_id, 7, '#', '', 1, 0, 'F', '0', '0', 'risk:auditFile:remove', '#', 103, 1, NOW(), '');

-- ============================================
-- 7. 风险警示
-- ============================================
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, remark)
VALUES ('风险警示', @risk_parent_id, 6, 'warning', 'risk/warning/index', 1, 0, 'C', '0', '0', 'risk:warning:list', '#', 103, 1, NOW(), '风险警示菜单');

SET @warning_id = LAST_INSERT_ID();

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, remark) VALUES
('警示查询', @warning_id, 1, '#', '', 1, 0, 'F', '0', '0', 'risk:warning:query', '#', 103, 1, NOW(), ''),
('警示新增', @warning_id, 2, '#', '', 1, 0, 'F', '0', '0', 'risk:warning:add', '#', 103, 1, NOW(), ''),
('警示修改', @warning_id, 3, '#', '', 1, 0, 'F', '0', '0', 'risk:warning:edit', '#', 103, 1, NOW(), ''),
('警示删除', @warning_id, 4, '#', '', 1, 0, 'F', '0', '0', 'risk:warning:remove', '#', 103, 1, NOW(), '');

-- ============================================
-- 8. 特种设备
-- ============================================
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, remark)
VALUES ('特种设备', @risk_parent_id, 7, 'specialEquipment', 'risk/specialEquipment/index', 1, 0, 'C', '0', '0', 'risk:specialEquipment:list', '#', 103, 1, NOW(), '特种设备菜单');

SET @special_equipment_id = LAST_INSERT_ID();

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, remark) VALUES
('设备查询', @special_equipment_id, 1, '#', '', 1, 0, 'F', '0', '0', 'risk:specialEquipment:query', '#', 103, 1, NOW(), ''),
('设备新增', @special_equipment_id, 2, '#', '', 1, 0, 'F', '0', '0', 'risk:specialEquipment:add', '#', 103, 1, NOW(), ''),
('设备修改', @special_equipment_id, 3, '#', '', 1, 0, 'F', '0', '0', 'risk:specialEquipment:edit', '#', 103, 1, NOW(), ''),
('设备删除', @special_equipment_id, 4, '#', '', 1, 0, 'F', '0', '0', 'risk:specialEquipment:remove', '#', 103, 1, NOW(), ''),
('设备维护查询', @special_equipment_id, 5, '#', '', 1, 0, 'F', '0', '0', 'risk:equipmentMaintenance:list', '#', 103, 1, NOW(), ''),
('设备维护新增', @special_equipment_id, 6, '#', '', 1, 0, 'F', '0', '0', 'risk:equipmentMaintenance:add', '#', 103, 1, NOW(), ''),
('设备维护修改', @special_equipment_id, 7, '#', '', 1, 0, 'F', '0', '0', 'risk:equipmentMaintenance:edit', '#', 103, 1, NOW(), ''),
('设备维护删除', @special_equipment_id, 8, '#', '', 1, 0, 'F', '0', '0', 'risk:equipmentMaintenance:remove', '#', 103, 1, NOW(), '');

-- ============================================
-- 9. 舆情推送
-- ============================================
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, remark)
VALUES ('舆情推送', @risk_parent_id, 8, 'publicOpinion', 'risk/publicOpinion/index', 1, 0, 'C', '0', '0', 'risk:publicOpinion:list', '#', 103, 1, NOW(), '舆情推送菜单');

SET @public_opinion_id = LAST_INSERT_ID();

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, remark) VALUES
('舆情查询', @public_opinion_id, 1, '#', '', 1, 0, 'F', '0', '0', 'risk:publicOpinion:query', '#', 103, 1, NOW(), ''),
('舆情新增', @public_opinion_id, 2, '#', '', 1, 0, 'F', '0', '0', 'risk:publicOpinion:add', '#', 103, 1, NOW(), ''),
('舆情修改', @public_opinion_id, 3, '#', '', 1, 0, 'F', '0', '0', 'risk:publicOpinion:edit', '#', 103, 1, NOW(), ''),
('舆情删除', @public_opinion_id, 4, '#', '', 1, 0, 'F', '0', '0', 'risk:publicOpinion:remove', '#', 103, 1, NOW(), ''),
('舆情处理', @public_opinion_id, 5, '#', '', 1, 0, 'F', '0', '0', 'risk:publicOpinion:handle', '#', 103, 1, NOW(), '');

-- ============================================
-- 10. 事故上报
-- ============================================
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, remark)
VALUES ('事故上报', @risk_parent_id, 9, 'accident', 'risk/accident/index', 1, 0, 'C', '0', '0', 'risk:accident:list', '#', 103, 1, NOW(), '事故上报菜单');

SET @accident_id = LAST_INSERT_ID();

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, remark) VALUES
('事故查询', @accident_id, 1, '#', '', 1, 0, 'F', '0', '0', 'risk:accident:query', '#', 103, 1, NOW(), ''),
('事故新增', @accident_id, 2, '#', '', 1, 0, 'F', '0', '0', 'risk:accident:add', '#', 103, 1, NOW(), ''),
('事故修改', @accident_id, 3, '#', '', 1, 0, 'F', '0', '0', 'risk:accident:edit', '#', 103, 1, NOW(), ''),
('事故删除', @accident_id, 4, '#', '', 1, 0, 'F', '0', '0', 'risk:accident:remove', '#', 103, 1, NOW(), '');

-- ============================================
-- 11. 巡检管理
-- ============================================
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, remark)
VALUES ('巡检任务', @risk_parent_id, 10, 'inspectionTask', 'risk/inspectionTask/index', 1, 0, 'C', '0', '0', 'risk:inspectionTask:list', '#', 103, 1, NOW(), '巡检任务菜单');

SET @inspection_task_id = LAST_INSERT_ID();

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, remark) VALUES
('巡检任务查询', @inspection_task_id, 1, '#', '', 1, 0, 'F', '0', '0', 'risk:inspectionTask:query', '#', 103, 1, NOW(), ''),
('巡检任务新增', @inspection_task_id, 2, '#', '', 1, 0, 'F', '0', '0', 'risk:inspectionTask:add', '#', 103, 1, NOW(), ''),
('巡检任务修改', @inspection_task_id, 3, '#', '', 1, 0, 'F', '0', '0', 'risk:inspectionTask:edit', '#', 103, 1, NOW(), ''),
('巡检任务删除', @inspection_task_id, 4, '#', '', 1, 0, 'F', '0', '0', 'risk:inspectionTask:remove', '#', 103, 1, NOW(), ''),
('巡检项目查询', @inspection_task_id, 5, '#', '', 1, 0, 'F', '0', '0', 'risk:inspectionItem:list', '#', 103, 1, NOW(), ''),
('巡检项目新增', @inspection_task_id, 6, '#', '', 1, 0, 'F', '0', '0', 'risk:inspectionItem:add', '#', 103, 1, NOW(), ''),
('巡检项目修改', @inspection_task_id, 7, '#', '', 1, 0, 'F', '0', '0', 'risk:inspectionItem:edit', '#', 103, 1, NOW(), ''),
('巡检项目删除', @inspection_task_id, 8, '#', '', 1, 0, 'F', '0', '0', 'risk:inspectionItem:remove', '#', 103, 1, NOW(), '');

-- ============================================
-- 12. 文件上传
-- ============================================
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, remark)
VALUES ('文件上传', @risk_parent_id, 11, '#', '', 1, 0, 'F', '0', '0', 'risk:file:upload', '#', 103, 1, NOW(), '文件上传');
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, remark)
VALUES ('文件删除', @risk_parent_id, 12, '#', '', 1, 0, 'F', '0', '0', 'risk:file:remove', '#', 103, 1, NOW(), '文件删除');

-- ============================================
-- 13. 风控大屏 (3.3 大屏菜单)
-- ============================================
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, remark)
VALUES ('风控大屏', @risk_parent_id, 0, 'bigScreen', 'risk/bigScreen/index', 1, 0, 'C', '0', '0', 'risk:bigScreen:view', 'data-board', 103, 1, NOW(), '风控品控管理平台大屏');

-- ============================================
-- 13. 给超级管理员角色授权所有风控平台权限
-- ============================================
INSERT INTO sys_role_menu (role_id, menu_id)
SELECT 1, menu_id FROM sys_menu WHERE perms LIKE 'risk:%';

-- 完成提示
SELECT '风控平台菜单权限初始化完成!' AS message,
       COUNT(*) AS total_menus
FROM sys_menu
WHERE perms LIKE 'risk:%';

-- ============================================
-- 14. 舆情推送字典数据
-- ============================================

-- 14.1 舆情来源字典
INSERT INTO sys_dict_type (dict_name, dict_type, create_dept, create_by, create_time, remark)
VALUES ('舆情来源', 'opinion_source', 103, 1, NOW(), '舆情来源列表');
SET @source_type_id = LAST_INSERT_ID();

INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_dept, create_by, create_time, remark) VALUES
(1, '新浪微博', '新浪微博', 'opinion_source', '', 'default', 'N', 103, 1, NOW(), ''),
(2, '抖音', '抖音', 'opinion_source', '', 'default', 'N', 103, 1, NOW(), ''),
(3, '今日头条', '今日头条', 'opinion_source', '', 'default', 'N', 103, 1, NOW(), ''),
(4, '知乎', '知乎', 'opinion_source', '', 'default', 'N', 103, 1, NOW(), ''),
(5, '新闻媒体', '新闻媒体', 'opinion_source', '', 'default', 'N', 103, 1, NOW(), ''),
(6, '小红书', '小红书', 'opinion_source', '', 'default', 'N', 103, 1, NOW(), ''),
(7, '微信公众号', '微信公众号', 'opinion_source', '', 'default', 'N', 103, 1, NOW(), ''),
(8, '贴吧', '贴吧', 'opinion_source', '', 'default', 'N', 103, 1, NOW(), ''),
(9, '其他', '其他', 'opinion_source', '', 'default', 'N', 103, 1, NOW(), '');

-- 14.2 风险等级字典
INSERT INTO sys_dict_type (dict_name, dict_type, create_dept, create_by, create_time, remark)
VALUES ('风险等级', 'risk_opinion_level', 103, 1, NOW(), '风险等级列表');
SET @level_type_id = LAST_INSERT_ID();

INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_dept, create_by, create_time, remark) VALUES
(1, '重大', '重大', 'risk_opinion_level', '', 'danger', 'N', 103, 1, NOW(), '重大风险'),
(2, '较大', '较大', 'risk_opinion_level', '', 'warning', 'N', 103, 1, NOW(), '较大风险'),
(3, '一般', '一般', 'risk_opinion_level', '', 'success', 'N', 103, 1, NOW(), '一般风险');

-- 14.3 处置状态字典
INSERT INTO sys_dict_type (dict_name, dict_type, create_dept, create_by, create_time, remark)
VALUES ('处置状态', 'risk_opinion_status', 103, 1, NOW(), '处置状态列表');
SET @status_type_id = LAST_INSERT_ID();

INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_dept, create_by, create_time, remark) VALUES
(1, '待处理', '待处理', 'risk_opinion_status', '', 'danger', 'N', 103, 1, NOW(), '待处理'),
(2, '处理中', '处理中', 'risk_opinion_status', '', 'warning', 'N', 103, 1, NOW(), '处理中'),
(3, '已处理', '已处理', 'risk_opinion_status', '', 'success', 'N', 103, 1, NOW(), '已处理');
