Files
xiaoqu_mcp_service/xiaoqu-franchisee/doc/hardware-install-log-export-auth.sql
T

37 lines
1.9 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.
-- ============================================================================
-- 装机轨迹日志页新增"导出"按钮 — 权限库 SQL
-- 功能:/hardwareInstallLog/export(HardwareInstallLogController)
-- 权限库三环境 schema(切环境只需改第一行 USE):
-- dev → xiaoqu_comples_d(2026-09-17 已执行)
-- test → test
-- prd → xiaoqu_comples_p
-- 幂等:NOT EXISTS 守卫,可重复执行
-- ============================================================================
USE xiaoqu_comples_d; -- test 改 USE test; prd 改 USE xiaoqu_comples_p;
START TRANSACTION;
-- 装机轨迹日志页(web_id=126,path=installationTrackLog)头按钮:导出
-- 页 id 不写死,按 path 动态取(三环境自增 id 可能不同)
SET @web_id := (SELECT id FROM webpage WHERE `path` = 'installationTrackLog' AND soft_delete = 0 LIMIT 1);
INSERT INTO button (web_id, cn_name, en_name, icon, class_name, function_path, `type`, `status`, order_by, theme, memo)
SELECT @web_id, '导出', 'export', '', '', '', 1, 0, 0, 'success', ''
FROM DUAL WHERE @web_id IS NOT NULL
AND NOT EXISTS (SELECT 1 FROM button WHERE web_id=@web_id AND en_name='export' AND soft_delete=0);
SET @b := LAST_INSERT_ID();
INSERT INTO button_webpage_authority (web_id, authority_id, cn_name, en_name, button_id, order_by, check_status, param, icon, `type`, class_name, theme, memo)
SELECT @web_id, wa.authority_id, '导出', 'export', @b, 0, 1, '', '', 1, '', 'success', ''
FROM (SELECT DISTINCT authority_id FROM webpage_authority WHERE web_id=@web_id AND soft_delete=0) wa
WHERE @b > 0;
-- 校验段
SELECT @web_id AS web_id, @b AS new_button_id,
(SELECT COUNT(*) FROM button_webpage_authority WHERE web_id=@web_id AND button_id=@b) AS auth_rows;
-- 期待:web_id 非空;new_button_id>0(已存在则为0且幂等跳过);auth_rows=该页授权组数
COMMIT;
-- 失败请改 ROLLBACK