Files
doorcontrol/base/RuoYi-Vue-master/sql/upgrade_d22_systime.sql
T
zfjia 271e4ca77c chore: 导入门锁迭代开发工程基线
包含 RuoYi-Vue 后端(ruoyi-iot 门禁模块)、RuoYi-Vue2 前端、设计文档与升级脚本。
忽略构建产物(target/node_modules/dist)、IDE 配置、运行日志与数据库转储。
2026-11-01 19:44:40 +08:00

72 lines
4.5 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.
-- =========================================================================
-- 存量升级:D22 服务器系统时间校时(v1 库)
--
-- 背景:开门授权依赖时间窗(人脸/密码有效期按绝对时间下发与校验),
-- 门锁系统将部署在 Linux 服务器上,内网离线环境缺少时间源时
-- 服务器时钟漂移会直接影响授权有效期、到期任务与日志时序,
-- 因此提供「门禁管理 › 系统时间」页面:查看服务器时间/时区/NTP 状态,
-- 由管理员手动校时或开关 NTP 自动同步。
--
-- 行为说明:
-- 1) 本脚本只加菜单,不建表(时间信息来自操作系统,不落库);
-- 2) 修改系统时间是高危操作,需在 application.yml 打开
-- iot.time.control-enabled=true,并满足:Linux + systemd(timedatectl)、
-- 服务以 root 运行或配置免密 sudo(iot.time.use-sudo=true);
-- 3) 默认 control-enabled=false,页面只读,不会误改服务器时钟。
--
-- 号段:2150 页面 + 2151–2152 按钮。2140–2142 已被 D20 P2 回调任务占用,
-- 本脚本不得再使用;若后续再加菜单请从 2153 往后排。
--
-- 幂等性:菜单只按自身 perms 删除再插入,不按号段整段删除;可重复执行。
--
-- 执行前置:备份 sys_menu。
-- =========================================================================
set names utf8mb4;
-- =========================================================================
-- 0、修复:D22 早前版本误用 2140–2142(与 D20 P2 回调任务号段冲突),
-- 其中 `delete from sys_menu where menu_id = 2140` 会删掉「回调任务」父菜单。
-- 先清掉可能残留的本模块菜单,再确保 2140 回调任务父菜单存在。
-- (若从未执行过旧版脚本,本段为空操作。)
-- =========================================================================
delete from sys_menu where perms like 'lock:time:%';
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, route_name, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark) values
(2140, '回调任务', 2000, 13, 'callback', 'iot/callback/index', '', '', 1, 0, 'C', '0', '0', 'lock:callback:list', 'message', 'admin', CURRENT_TIMESTAMP, '开放接口结果回调任务')
on duplicate key update menu_name = menu_name;
-- =========================================================================
-- 1、菜单:门禁管理 › 系统时间
-- 2150 页面(perms 即查询权限),2151–2152 操作按钮;接在住宿 2130 之后。
-- =========================================================================
delete from sys_menu where menu_id in (2150, 2151, 2152);
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, route_name, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark) values
(2150, '系统时间', 2000, 14, 'systime', 'iot/systime/index', '', '', 1, 0, 'C', '0', '0', 'lock:time:query', 'time', 'admin', CURRENT_TIMESTAMP, '服务器时间查看、手动校时与 NTP 开关');
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, route_name, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark) values
(2151, '手动校时', 2150, 1, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:time:set', '#', 'admin', CURRENT_TIMESTAMP, '需 root 或免密 sudo'),
(2152, 'NTP开关', 2150, 2, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:time:ntp', '#', 'admin', CURRENT_TIMESTAMP, '开关 NTP 自动同步');
-- =========================================================================
-- 2、核对(执行后可跑一次)
-- =========================================================================
-- 2.1 本模块菜单:应为 3 行(2150 页面 + 2151/2152 按钮)
-- select menu_id, menu_name, parent_id, menu_type, perms from sys_menu
-- where menu_id between 2150 and 2152 order by menu_id;
-- 2.2 回调任务菜单必须仍在:应为 3 行(2140 父 + 2141/2142 按钮,parent_id 指向 2140)
-- select menu_id, menu_name, parent_id, menu_type, perms from sys_menu
-- where menu_id between 2140 and 2142 order by menu_id;
-- =========================================================================
-- 3、回滚
-- =========================================================================
-- delete from sys_menu where perms like 'lock:time:%';
-- delete from sys_menu where menu_id in (2150, 2151, 2152);