-- 初始化字典数据 -- 先删除旧数据 DELETE FROM `sys_dict_item` WHERE `id` > 0; DELETE FROM `sys_dict_type` WHERE `id` > 0; ALTER TABLE `sys_dict_type` AUTO_INCREMENT = 1; ALTER TABLE `sys_dict_item` AUTO_INCREMENT = 1; -- 插入字典类型 INSERT INTO `sys_dict_type` (`tenant_id`, `dict_code`, `dict_name`, `parent_id`, `status`, `sort`, `remark`, `create_by`) VALUES (0, 'user_status', '用户状态', 0, 1, 1, '用户启用禁用状态', 'system'), (0, 'user_gender', '用户性别', 0, 1, 2, '用户性别', 'system'), (0, 'position_status', '职位状态', 0, 1, 3, '职位启用禁用状态', 'system'), (0, 'dept_status', '部门状态', 0, 1, 4, '部门启用禁用状态', 'system'); -- 插入用户状态字典项 -- 假设 user_status 字典类型 ID 为 1 INSERT INTO `sys_dict_item` (`dict_type_id`, `dict_label`, `dict_value`, `parent_id`, `status`, `sort`, `color`, `remark`, `create_by`) VALUES (1, '启用', '1', 0, 1, 1, '#67C23A', '用户启用状态', 'system'), (1, '禁用', '0', 0, 1, 2, '#F56C6C', '用户禁用状态', 'system'); -- 插入用户性别字典项 -- 假设 user_gender 字典类型 ID 为 2 INSERT INTO `sys_dict_item` (`dict_type_id`, `dict_label`, `dict_value`, `parent_id`, `status`, `sort`, `color`, `remark`, `create_by`) VALUES (2, '男', 'M', 0, 1, 1, '#409EFF', '男性', 'system'), (2, '女', 'F', 0, 1, 2, '#E6A23C', '女性', 'system'), (2, '其他', 'O', 0, 1, 3, '#909399', '其他性别', 'system'); -- 插入职位状态字典项 -- 假设 position_status 字典类型 ID 为 3 INSERT INTO `sys_dict_item` (`dict_type_id`, `dict_label`, `dict_value`, `parent_id`, `status`, `sort`, `color`, `remark`, `create_by`) VALUES (3, '启用', '1', 0, 1, 1, '#67C23A', '职位启用状态', 'system'), (3, '禁用', '0', 0, 1, 2, '#F56C6C', '职位禁用状态', 'system'); -- 插入部门状态字典项 -- 假设 dept_status 字典类型 ID 为 4 INSERT INTO `sys_dict_item` (`dict_type_id`, `dict_label`, `dict_value`, `parent_id`, `status`, `sort`, `color`, `remark`, `create_by`) VALUES (4, '启用', '1', 0, 1, 1, '#67C23A', '部门启用状态', 'system'), (4, '禁用', '0', 0, 1, 2, '#F56C6C', '部门禁用状态', 'system');