-- H2数据库测试数据
-- 用于测试环境

-- 插入测试角色
INSERT INTO sys_role (id, role_name, role_key, role_sort, status, create_by, update_by) 
VALUES 
(1, '超级管理员', 'admin', 1, 1, 'system', 'system'),
(2, '测试管理员', 'test_admin', 2, 1, 'system', 'system'),
(3, '普通用户', 'normal_user', 3, 1, 'system', 'system'),
(4, '访客', 'guest', 4, 1, 'system', 'system');

-- 插入测试用户
-- BCrypt哈希值对应明文密码: Test@123
INSERT INTO sys_user (id, username, password, email, phone, nickname, status, create_by, update_by) 
VALUES 
(1, 'admin', '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/X4.VTtYA/7.J6LlZy', 'admin@novalon.com', '13800138000', '超级管理员', 1, 'system', 'system'),
(2, 'testadmin', '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/X4.VTtYA/7.J6LlZy', 'testadmin@novalon.com', '13800138001', '测试管理员', 1, 'system', 'system'),
(3, 'normaluser', '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/X4.VTtYA/7.J6LlZy', 'normaluser@novalon.com', '13800138002', '普通用户', 1, 'system', 'system'),
(4, 'guestuser', '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/X4.VTtYA/7.J6LlZy', 'guestuser@novalon.com', '13800138003', '访客用户', 1, 'system', 'system'),
(5, 'disableduser', '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/X4.VTtYA/7.J6LlZy', 'disableduser@novalon.com', '13800138004', '禁用用户', 0, 'system', 'system');

-- 为用户分配角色
INSERT INTO user_role (user_id, role_id, created_by)
VALUES 
(1, 1, 'system'),
(2, 2, 'system'),
(3, 3, 'system'),
(4, 4, 'system');

-- 插入测试菜单
INSERT INTO sys_menu (id, menu_name, parent_id, order_num, path, component, menu_type, visible, status, perms, icon, created_by, updated_by)
VALUES 
(1, '系统管理', 0, 1, '/system', 'Layout', 'M', '1', '1', '', 'system', 'system', 'system'),
(2, '用户管理', 1, 1, 'user', 'system/user/index', 'C', '1', '1', 'system:user:list', 'user', 'system', 'system'),
(3, '角色管理', 1, 2, 'role', 'system/role/index', 'C', '1', '1', 'system:role:list', 'role', 'system', 'system'),
(4, '菜单管理', 1, 3, 'menu', 'system/menu/index', 'C', '1', '1', 'system:menu:list', 'menu', 'system', 'system'),
(5, '测试菜单', 0, 99, '/test', 'Layout', 'M', '1', '1', '', 'test', 'system', 'system'),
(6, '用户测试', 5, 1, 'user-test', 'system/user-test/index', 'C', '1', '1', 'system:user:test', 'user', 'system', 'system');

-- 插入测试权限
INSERT INTO sys_permission (id, permission_name, permission_key, permission_type, parent_id, status, created_by, updated_by)
VALUES 
(1, '系统管理', 'system:manage', 'menu', 0, 1, 'system', 'system'),
(2, '用户管理', 'system:user:manage', 'menu', 1, 1, 'system', 'system'),
(3, '用户查询', 'system:user:list', 'button', 2, 1, 'system', 'system'),
(4, '用户新增', 'system:user:add', 'button', 2, 1, 'system', 'system'),
(5, '用户编辑', 'system:user:edit', 'button', 2, 1, 'system', 'system'),
(6, '用户删除', 'system:user:delete', 'button', 2, 1, 'system', 'system'),
(7, '测试权限', 'test:permission', 'menu', 0, 1, 'system', 'system'),
(8, '用户测试权限', 'system:user:test', 'button', 7, 1, 'system', 'system');

-- 为角色分配权限
INSERT INTO sys_role_permission (role_id, permission_id, created_by, updated_by)
SELECT 1, id, 'system', 'system' FROM sys_permission
UNION ALL
SELECT 2, id, 'system', 'system' FROM sys_permission WHERE id IN (7, 8);

-- 插入字典类型
INSERT INTO sys_dict_type (id, dict_name, dict_type, status, remark, created_by, updated_by) 
VALUES 
(1, '用户状态', 'user_status', '0', '用户状态列表', 'system', 'system'),
(2, '菜单状态', 'menu_status', '0', '菜单状态列表', 'system', 'system'),
(3, '角色状态', 'role_status', '0', '角色状态列表', 'system', 'system');

-- 插入字典数据
INSERT INTO sys_dict_data (id, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, created_by, updated_by) 
VALUES 
(1, 1, '正常', '1', 'user_status', '', 'primary', 'Y', '0', 'system', 'system'),
(2, 2, '停用', '0', 'user_status', '', 'danger', 'N', '0', 'system', 'system'),
(3, 1, '正常', '0', 'menu_status', '', 'primary', 'Y', '0', 'system', 'system'),
(4, 2, '停用', '1', 'menu_status', '', 'danger', 'N', '0', 'system', 'system'),
(5, 1, '正常', '0', 'role_status', '', 'primary', 'Y', '0', 'system', 'system'),
(6, 2, '停用', '1', 'role_status', '', 'danger', 'N', '0', 'system', 'system');

-- 插入系统配置
INSERT INTO sys_config (id, config_name, config_key, config_value, config_type, remark, created_by, updated_by) 
VALUES 
(1, '用户管理-用户初始密码', 'sys.user.initPassword', '123456', 'Y', '初始化用户密码', 'system', 'system'),
(2, '主框架页-默认皮肤样式名称', 'sys.index.skinName', 'skin-blue', 'Y', '默认皮肤', 'system', 'system'),
(3, '用户自助-验证码开关', 'sys.account.captchaEnabled', 'true', 'Y', '是否开启验证码功能', 'system', 'system');
