Files
game_server/docs/database_migration_add_user_fields.sql
zyh 3847250c2b feat: 添加用户端链接状态查询接口及自动刷新逻辑
主要修改:
1. 在LinkController中新增获取用户链接状态的接口,支持通过linkId或codeNo查询。
2. 在LinkStatusService中实现用户链接状态查询逻辑,包含自动刷新和二维码更新功能。
3. 更新LinkTask实体,添加needRefresh、refreshTime、qrCreatedAt和qrExpireAt字段以支持新功能。
4. 在ScriptClient中新增检查空闲设备、选区、刷新、检查上号状态等操作的实现。
5. 更新SecurityConfig,允许用户端获取链接状态接口公开访问。

技术细节:
- 新增UserLinkStatusResponse DTO以支持用户链接状态的返回格式。
- 通过脚本端接口实现链接状态的自动刷新和二维码信息更新。
2025-08-26 18:07:44 +08:00

34 lines
1.7 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 数据库迁移脚本为link_task表添加用户端需要的字段
-- 执行时间2025-01-XX
-- 说明:为支持用户端链接状态查询功能添加字段
-- 为link_task表添加新字段
ALTER TABLE `link_task`
ADD COLUMN `need_refresh` tinyint(1) NULL DEFAULT 0 COMMENT '是否需要刷新0否1是' AFTER `updated_at`,
ADD COLUMN `refresh_time` datetime(3) NULL DEFAULT NULL COMMENT '刷新时间' AFTER `need_refresh`,
ADD COLUMN `qr_created_at` datetime(3) NULL DEFAULT NULL COMMENT '二维码创建时间' AFTER `refresh_time`,
ADD COLUMN `qr_expire_at` datetime(3) NULL DEFAULT NULL COMMENT '二维码过期时间' AFTER `qr_created_at`;
-- 添加索引以优化查询性能
ALTER TABLE `link_task`
ADD INDEX `idx_need_refresh` (`need_refresh` ASC),
ADD INDEX `idx_qr_expire` (`qr_expire_at` ASC);
-- 更新系统配置,添加用户端相关配置
INSERT INTO `system_config` (`config_key`, `config_value`, `config_type`, `description`, `is_system`) VALUES
('user.qr_expire_seconds', '60', 'INTEGER', '用户端二维码有效期(秒)', 1),
('user.refresh_wait_seconds', '10', 'INTEGER', '用户端刷新等待时间(秒)', 1),
('user.link_expire_hours', '24', 'INTEGER', '用户端链接有效期(小时)', 1),
('user.assets_base_url', 'http://36.138.184.60:12345', 'STRING', '用户端静态资源基础URL', 1)
ON DUPLICATE KEY UPDATE
`config_value` = VALUES(`config_value`),
`updated_at` = CURRENT_TIMESTAMP(3);
-- 验证表结构变更
SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT, COLUMN_COMMENT
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'link_task'
AND COLUMN_NAME IN ('need_refresh', 'refresh_time', 'qr_created_at', 'qr_expire_at')
ORDER BY ORDINAL_POSITION;