feat: ✨ 新增系统配置页面
This commit is contained in:
98
sql/insert_config_data_compatible.sql
Normal file
98
sql/insert_config_data_compatible.sql
Normal file
@@ -0,0 +1,98 @@
|
||||
-- =============================================
|
||||
-- 梦幻西游运营管理系统 - 系统配置数据插入脚本 (兼容版)
|
||||
-- 版本: v1.0.5
|
||||
-- 创建日期: 2025-12-12
|
||||
-- 描述: 插入系统配置数据,完全兼容现有表结构
|
||||
-- =============================================
|
||||
|
||||
-- 切换到目标数据库
|
||||
USE mhxy_web;
|
||||
|
||||
-- =============================================
|
||||
-- 1. 创建配置历史记录表 (如果不存在)
|
||||
-- =============================================
|
||||
CREATE TABLE IF NOT EXISTS system_config_history (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY COMMENT '记录ID',
|
||||
config_key VARCHAR(100) NOT NULL COMMENT '配置键名',
|
||||
old_value TEXT COMMENT '原配置值',
|
||||
new_value TEXT COMMENT '新配置值',
|
||||
changed_by INT COMMENT '修改人用户ID',
|
||||
changed_reason VARCHAR(500) COMMENT '修改原因',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||
|
||||
INDEX idx_config_key (config_key),
|
||||
INDEX idx_created_at (created_at)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='系统配置历史记录表';
|
||||
|
||||
-- =============================================
|
||||
-- 2. 创建配置缓存表 (如果不存在)
|
||||
-- =============================================
|
||||
CREATE TABLE IF NOT EXISTS system_config_cache (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY COMMENT '缓存ID',
|
||||
cache_key VARCHAR(100) NOT NULL UNIQUE COMMENT '缓存键',
|
||||
cache_value LONGTEXT COMMENT '缓存值(JSON格式)',
|
||||
expires_at TIMESTAMP COMMENT '过期时间',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
|
||||
INDEX idx_cache_key (cache_key),
|
||||
INDEX idx_expires_at (expires_at)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='系统配置缓存表';
|
||||
|
||||
-- =============================================
|
||||
-- 3. 清空并重新插入配置数据
|
||||
-- =============================================
|
||||
|
||||
-- 先删除所有现有配置数据
|
||||
DELETE FROM system_config;
|
||||
|
||||
-- 插入基本配置 (使用现有表字段)
|
||||
INSERT INTO system_config (config_key, config_value, config_desc, config_group) VALUES
|
||||
('site_name', '梦幻西游一站式运营管理系统', '系统显示名称', 'basic'),
|
||||
('site_version', '1.0.0', '当前系统版本号', 'basic'),
|
||||
('site_description', '专业的游戏运营管理平台', '系统描述信息', 'basic'),
|
||||
('admin_email', 'admin@mhxy.com', '系统管理员联系邮箱', 'basic'),
|
||||
('maintenance_mode', '0', '开启后用户无法正常访问系统', 'basic'),
|
||||
('default_language', 'zh-CN', '系统默认语言设置', 'basic');
|
||||
|
||||
-- 插入安全配置
|
||||
INSERT INTO system_config (config_key, config_value, config_desc, config_group) VALUES
|
||||
('jwt_secret', 'JWT_SECRET_32_BYTE_RANDOM_STRING_2025', '用于JWT令牌签名的密钥,建议32位字符', 'security'),
|
||||
('jwt_expires_in', '24', 'JWT访问令牌的有效期,单位:小时', 'security'),
|
||||
('jwt_refresh_expires_in', '168', 'JWT刷新令牌的有效期,单位:小时', 'security'),
|
||||
('login_attempt_limit', '5', '连续登录失败次数限制', 'security'),
|
||||
('session_timeout', '30', '用户会话超时时间', 'security'),
|
||||
('password_min_length', '6', '用户密码最小长度要求', 'security'),
|
||||
('enable_2fa', '0', '是否启用双因子认证功能', 'security');
|
||||
|
||||
-- 插入游戏通信配置
|
||||
INSERT INTO system_config (config_key, config_value, config_desc, config_group) VALUES
|
||||
('game_server_api', 'http://127.0.0.1:8080/tool/http', '游戏服务端HTTP接口地址', 'game'),
|
||||
('game_server_psk', 'THIS_IS_A_32_BYTE_FIXED_PSK!!!!!', '游戏服务端预共享密钥,用于API认证', 'game'),
|
||||
('game_server_timeout', '30', '与游戏服务端通信的超时时间', 'game'),
|
||||
('game_server_retry_count', '3', 'API请求失败时的重试次数', 'game'),
|
||||
('player_auto_register', '1', '新玩家是否自动创建账号', 'game'),
|
||||
('game_log_level', 'info', '游戏相关操作的日志记录级别', 'game');
|
||||
|
||||
-- =============================================
|
||||
-- 4. 验证结果
|
||||
-- =============================================
|
||||
|
||||
-- 检查当前表结构
|
||||
DESCRIBE system_config;
|
||||
|
||||
-- 检查各组配置数量
|
||||
SELECT config_group, COUNT(*) as config_count
|
||||
FROM system_config
|
||||
GROUP BY config_group;
|
||||
|
||||
-- 检查关键配置
|
||||
SELECT config_key, config_value, config_desc
|
||||
FROM system_config
|
||||
WHERE config_key IN ('jwt_secret', 'game_server_api', 'game_server_psk');
|
||||
|
||||
-- 检查新表是否创建成功
|
||||
SHOW TABLES LIKE 'system_config_history';
|
||||
SHOW TABLES LIKE 'system_config_cache';
|
||||
|
||||
-- 完成提示
|
||||
SELECT 'System config data inserted successfully with compatible fields!' as message;
|
||||
Reference in New Issue
Block a user