-- 创建登录尝试记录表 -- 用于记录登录失败次数,支持账号锁定功能 -- 与技术方案中的 max_login_attempts 和 login_lockout_minutes 配置对应 CREATE TABLE IF NOT EXISTS login_attempts ( id INT AUTO_INCREMENT PRIMARY KEY COMMENT '主键ID', -- 基本信息 username VARCHAR(100) NOT NULL COMMENT '用户名', success TINYINT(1) DEFAULT 0 COMMENT '是否成功: 1-成功, 0-失败', -- 登录环境信息 machine_code VARCHAR(255) COMMENT '机器码', ip_address VARCHAR(45) COMMENT 'IP地址', user_agent VARCHAR(500) COMMENT '用户代理', failure_reason VARCHAR(255) COMMENT '失败原因', -- 时间戳 attempted_at DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '尝试时间', -- 索引 INDEX idx_login_attempt_user (username), INDEX idx_login_attempt_time (attempted_at), INDEX idx_login_attempt_user_time (username, attempted_at) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='登录尝试记录表'; -- 初始化客户端核心配置项 INSERT INTO system_config (config_key, config_value, config_type, app_name, description, is_system, is_editable) VALUES -- 心跳相关配置 ('heartbeat_interval_seconds', '10', 'int', 'backend-client', '心跳检测间隔秒数', 1, 1), ('max_heartbeat_failures', '100', 'int', 'backend-client', '心跳最大失败次数', 1, 1), -- Session自动续期配置 ('session_renewal_threshold', '1800', 'int', 'backend-client', 'Session续期阈值(秒),剩余时间小于此值时触发续期', 1, 1), ('session_extension_duration', '3600', 'int', 'backend-client', 'Session延长时间(秒),续期时延长的时长', 1, 1), ('session_default_expiry_seconds', '86400', 'int', 'backend-client', 'Session默认有效期(秒),新登录时创建的有效期', 1, 1), -- 安全相关配置 ('timestamp_tolerance_seconds', '300', 'int', 'backend-client', '时间戳容忍秒数(±5分钟)', 1, 1), ('prevent_duplicate_login', 'true', 'bool', 'backend-client', '是否防止重复登录', 1, 1), -- 登录相关配置 ('max_login_attempts', '5', 'int', 'backend-client', '最大登录失败次数', 1, 1), ('login_lockout_minutes', '60', 'int', 'backend-client', '登录锁定分钟数', 1, 1), -- 公告相关配置 ('announcement_cache_seconds', '300', 'int', 'backend-client', '公告缓存秒数', 1, 1), -- 密钥相关配置 ('key_sync_interval_seconds', '60', 'int', 'backend-client', '密钥同步间隔秒数', 1, 1) ON DUPLICATE KEY UPDATE description=VALUES(description); -- 初始化默认软件 INSERT INTO software (code, name, daily_price, is_active) VALUES ('buff-xp-steam-sh', '游铛铛(BUFF选品和Steam扫货工具)', 1, 1) ON DUPLICATE KEY UPDATE name=VALUES(name), daily_price=VALUES(daily_price);