-- ============================================================
-- RuoYi系统表中文乱码修复SQL
-- 作者：pangu
-- 创建时间：2026-01-31
-- 说明：修复sys_role、sys_dept等表中的中文乱码
-- 使用方法：mysql -h8.148.25.55 -P3306 -uroot -p --default-character-set=utf8mb4 pguser-db < fix_ruoyi_charset.sql
-- ============================================================

-- 1. 修复角色表（sys_role）
UPDATE sys_role SET role_name = '超级管理员', remark = '超级管理员' WHERE role_id = 1;
UPDATE sys_role SET role_name = '普通角色', remark = '普通角色' WHERE role_id = 2;

-- 2. 修复部门表（sys_dept）
UPDATE sys_dept SET dept_name = '若依科技', leader = '若依' WHERE dept_id = 100;
UPDATE sys_dept SET dept_name = '深圳总公司', leader = '若依' WHERE dept_id = 101;
UPDATE sys_dept SET dept_name = '长沙分公司', leader = '若依' WHERE dept_id = 102;
UPDATE sys_dept SET dept_name = '研发部门', leader = '若依' WHERE dept_id = 103;
UPDATE sys_dept SET dept_name = '市场部门', leader = '若依' WHERE dept_id = 104;
UPDATE sys_dept SET dept_name = '测试部门', leader = '若依' WHERE dept_id = 105;
UPDATE sys_dept SET dept_name = '财务部门', leader = '若依' WHERE dept_id = 106;
UPDATE sys_dept SET dept_name = '运维部门', leader = '若依' WHERE dept_id = 107;
UPDATE sys_dept SET dept_name = '市场部门', leader = '若依' WHERE dept_id = 108;
UPDATE sys_dept SET dept_name = '财务部门', leader = '若依' WHERE dept_id = 109;

-- 3. 修复用户表（sys_user）
UPDATE sys_user SET nick_name = '管理员' WHERE user_id = 1;
UPDATE sys_user SET nick_name = '若依' WHERE user_id = 2;

-- 4. 修复岗位表（sys_post）
UPDATE sys_post SET post_name = '董事长', remark = '' WHERE post_id = 1;
UPDATE sys_post SET post_name = '项目经理', remark = '' WHERE post_id = 2;
UPDATE sys_post SET post_name = '人力资源', remark = '' WHERE post_id = 3;
UPDATE sys_post SET post_name = '普通员工', remark = '' WHERE post_id = 4;

-- 5. 修复字典类型表（sys_dict_type）
UPDATE sys_dict_type SET dict_name = '用户性别' WHERE dict_type = 'sys_user_sex';
UPDATE sys_dict_type SET dict_name = '菜单状态' WHERE dict_type = 'sys_show_hide';
UPDATE sys_dict_type SET dict_name = '系统开关' WHERE dict_type = 'sys_normal_disable';
UPDATE sys_dict_type SET dict_name = '任务状态' WHERE dict_type = 'sys_job_status';
UPDATE sys_dict_type SET dict_name = '任务分组' WHERE dict_type = 'sys_job_group';
UPDATE sys_dict_type SET dict_name = '系统是否' WHERE dict_type = 'sys_yes_no';
UPDATE sys_dict_type SET dict_name = '通知类型' WHERE dict_type = 'sys_notice_type';
UPDATE sys_dict_type SET dict_name = '通知状态' WHERE dict_type = 'sys_notice_status';
UPDATE sys_dict_type SET dict_name = '操作类型' WHERE dict_type = 'sys_oper_type';
UPDATE sys_dict_type SET dict_name = '系统状态' WHERE dict_type = 'sys_common_status';

-- 6. 修复字典数据表（sys_dict_data）
-- 用户性别
UPDATE sys_dict_data SET dict_label = '男' WHERE dict_code = 1;
UPDATE sys_dict_data SET dict_label = '女' WHERE dict_code = 2;
UPDATE sys_dict_data SET dict_label = '未知' WHERE dict_code = 3;

-- 菜单状态
UPDATE sys_dict_data SET dict_label = '显示' WHERE dict_code = 4;
UPDATE sys_dict_data SET dict_label = '隐藏' WHERE dict_code = 5;

-- 系统开关
UPDATE sys_dict_data SET dict_label = '正常' WHERE dict_code = 6;
UPDATE sys_dict_data SET dict_label = '停用' WHERE dict_code = 7;

-- 任务状态
UPDATE sys_dict_data SET dict_label = '正常' WHERE dict_code = 8;
UPDATE sys_dict_data SET dict_label = '暂停' WHERE dict_code = 9;

-- 任务分组
UPDATE sys_dict_data SET dict_label = '默认' WHERE dict_code = 10;
UPDATE sys_dict_data SET dict_label = '系统' WHERE dict_code = 11;

-- 系统是否
UPDATE sys_dict_data SET dict_label = '是' WHERE dict_code = 12;
UPDATE sys_dict_data SET dict_label = '否' WHERE dict_code = 13;

-- 通知类型
UPDATE sys_dict_data SET dict_label = '通知' WHERE dict_code = 14;
UPDATE sys_dict_data SET dict_label = '公告' WHERE dict_code = 15;

-- 通知状态
UPDATE sys_dict_data SET dict_label = '正常' WHERE dict_code = 16;
UPDATE sys_dict_data SET dict_label = '关闭' WHERE dict_code = 17;

-- 操作类型
UPDATE sys_dict_data SET dict_label = '其他' WHERE dict_code = 18;
UPDATE sys_dict_data SET dict_label = '新增' WHERE dict_code = 19;
UPDATE sys_dict_data SET dict_label = '修改' WHERE dict_code = 20;
UPDATE sys_dict_data SET dict_label = '删除' WHERE dict_code = 21;
UPDATE sys_dict_data SET dict_label = '授权' WHERE dict_code = 22;
UPDATE sys_dict_data SET dict_label = '导出' WHERE dict_code = 23;
UPDATE sys_dict_data SET dict_label = '导入' WHERE dict_code = 24;
UPDATE sys_dict_data SET dict_label = '强退' WHERE dict_code = 25;
UPDATE sys_dict_data SET dict_label = '生成代码' WHERE dict_code = 26;
UPDATE sys_dict_data SET dict_label = '清空数据' WHERE dict_code = 27;

-- 系统状态
UPDATE sys_dict_data SET dict_label = '成功' WHERE dict_code = 28;
UPDATE sys_dict_data SET dict_label = '失败' WHERE dict_code = 29;

-- 7. 修复配置表（sys_config）
UPDATE sys_config SET config_name = '主框架页-默认皮肤样式名称' WHERE config_id = 1;
UPDATE sys_config SET config_name = '用户管理-账号初始密码' WHERE config_id = 2;
UPDATE sys_config SET config_name = '主框架页-侧边栏主题' WHERE config_id = 3;
UPDATE sys_config SET config_name = '账号自助-验证码开关' WHERE config_id = 4;
UPDATE sys_config SET config_name = '账号自助-是否开启用户注册功能' WHERE config_id = 5;
UPDATE sys_config SET config_name = '用户登录-黑名单列表' WHERE config_id = 11;

SELECT '✅ RuoYi系统表中文乱码修复完成！' AS status;
