-- ============================================================
-- 菜单初始数据
-- ============================================================
USE `qconline`;

-- 清空菜单表
TRUNCATE TABLE `menu`;

-- 1. 系统管理（一级菜单）
INSERT INTO `menu` VALUES ('1', '系统管理', 'system', '0', 1, '/system', 'Layout', 'Setting', 1, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('101', '用户管理', 'system:user', '1', 2, '/system/user', 'system/user/index', 'User', 1, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('102', '机构管理', 'system:institution', '1', 2, '/system/institution', 'system/institution/index', 'OfficeBuilding', 2, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('103', '菜单权限', 'system:menu', '1', 2, '/system/menu', 'system/menu/index', 'Menu', 3, 1, NOW(), NOW());

-- 用户管理按钮权限
INSERT INTO `menu` VALUES ('10101', '用户查询', 'system:user:query', '101', 3, NULL, NULL, NULL, 1, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('10102', '用户新增', 'system:user:add', '101', 3, NULL, NULL, NULL, 2, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('10103', '用户编辑', 'system:user:edit', '101', 3, NULL, NULL, NULL, 3, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('10104', '用户删除', 'system:user:delete', '101', 3, NULL, NULL, NULL, 4, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('10105', '重置密码', 'system:user:resetPwd', '101', 3, NULL, NULL, NULL, 5, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('10106', '机构权限', 'system:user:institution', '101', 3, NULL, NULL, NULL, 6, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('10107', '菜单权限', 'system:user:menu', '101', 3, NULL, NULL, NULL, 7, 1, NOW(), NOW());

-- 2. 患者管理（一级菜单）
INSERT INTO `menu` VALUES ('2', '患者管理', 'patient', '0', 1, '/patient', 'Layout', 'User', 2, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('201', '患者列表', 'patient:list', '2', 2, '/patient/list', 'patient/list/index', 'UserFilled', 1, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('202', '检查列表', 'patient:study', '2', 2, '/patient/study', 'patient/study/index', 'DocumentCopy', 2, 1, NOW(), NOW());

-- 患者管理按钮权限
INSERT INTO `menu` VALUES ('20101', '患者查询', 'patient:list:query', '201', 3, NULL, NULL, NULL, 1, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('20102', '查看详情', 'patient:list:detail', '201', 3, NULL, NULL, NULL, 2, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('20201', '检查查询', 'patient:study:query', '202', 3, NULL, NULL, NULL, 1, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('20202', '查看影像', 'patient:study:viewer', '202', 3, NULL, NULL, NULL, 2, 1, NOW(), NOW());

-- 3. 质控管理（一级菜单）
INSERT INTO `menu` VALUES ('3', '质控管理', 'qc', '0', 1, '/qc', 'Layout', 'Document', 3, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('301', '质控因子', 'qc:factor', '3', 2, '/qc/factor', 'qc/factor/index', 'Compass', 1, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('302', '质控标准', 'qc:standard', '3', 2, '/qc/standard', 'qc/standard/index', 'Medal', 2, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('303', '质控任务', 'qc:task', '3', 2, '/qc/task', 'qc/task/index', 'Calendar', 3, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('304', '质控结果', 'qc:result', '3', 2, '/qc/result', 'qc/result/index', 'DataAnalysis', 4, 1, NOW(), NOW());

-- 质控管理按钮权限
INSERT INTO `menu` VALUES ('30101', '因子查询', 'qc:factor:query', '301', 3, NULL, NULL, NULL, 1, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('30102', '因子新增', 'qc:factor:add', '301', 3, NULL, NULL, NULL, 2, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('30103', '因子编辑', 'qc:factor:edit', '301', 3, NULL, NULL, NULL, 3, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('30104', '因子删除', 'qc:factor:delete', '301', 3, NULL, NULL, NULL, 4, 1, NOW(), NOW());

INSERT INTO `menu` VALUES ('30201', '标准查询', 'qc:standard:query', '302', 3, NULL, NULL, NULL, 1, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('30202', '标准新增', 'qc:standard:add', '302', 3, NULL, NULL, NULL, 2, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('30203', '标准编辑', 'qc:standard:edit', '302', 3, NULL, NULL, NULL, 3, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('30204', '标准删除', 'qc:standard:delete', '302', 3, NULL, NULL, NULL, 4, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('30205', '标准配置', 'qc:standard:config', '302', 3, NULL, NULL, NULL, 5, 1, NOW(), NOW());

INSERT INTO `menu` VALUES ('30301', '任务查询', 'qc:task:query', '303', 3, NULL, NULL, NULL, 1, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('30302', '任务创建', 'qc:task:create', '303', 3, NULL, NULL, NULL, 2, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('30303', '任务详情', 'qc:task:detail', '303', 3, NULL, NULL, NULL, 3, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('30304', '任务停止', 'qc:task:stop', '303', 3, NULL, NULL, NULL, 4, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('30305', '任务删除', 'qc:task:delete', '303', 3, NULL, NULL, NULL, 5, 1, NOW(), NOW());

INSERT INTO `menu` VALUES ('30401', '结果查询', 'qc:result:query', '304', 3, NULL, NULL, NULL, 1, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('30402', '结果详情', 'qc:result:detail', '304', 3, NULL, NULL, NULL, 2, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('30403', '结果导出', 'qc:result:export', '304', 3, NULL, NULL, NULL, 3, 1, NOW(), NOW());

-- 4. 统计分析（一级菜单）
INSERT INTO `menu` VALUES ('4', '统计分析', 'dashboard', '0', 1, '/dashboard', 'Layout', 'DataLine', 4, 1, NOW(), NOW());
INSERT INTO `menu` VALUES ('401', '质控概览', 'dashboard:overview', '4', 2, '/dashboard/overview', 'dashboard/overview/index', 'Monitor', 1, 1, NOW(), NOW());

-- 管理员账号（密码：admin123，需要MD5加密）
-- 注意：实际使用时需要用MD5WithSalt加密
INSERT INTO `sys_user` VALUES
('1', 'admin', '21232f297a57a5a743894a0e4a801fc3', '系统管理员', '13800138000', 'admin@qconline.com', NULL, 1, 1, NOW(), NOW());

-- 管理员拥有所有菜单权限
INSERT INTO `user_menu`
SELECT UUID(), '1', id, NOW() FROM menu WHERE status = 1;
