admin/sql/fix_xhs_menu_parent.sql
zzh ffaf325563 fix(xhs): repair publish/task list SQL and RBAC menu seeds
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 11:23:37 +08:00

54 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.

-- 修复小红书菜单层级与「启动服务」消失问题
-- RBAC 库执行
--
-- 原因:
-- 1. 一级「小红书」PId 必须为 00000000-0000-0000-0000-000000000000
-- 2. 一级目录 PermissionCode 必须为空字符串(列 NOT NULL,不可写 NULL;勿与「启动服务」同权限码)
SET @ROOT_PID = '00000000-0000-0000-0000-000000000000';
SET @XHS_PID = 'a1b2c3d4-e5f6-7890-abcd-ef1234567801';
-- 一级:小红书(目录,PermissionCode 空字符串)
UPDATE `menu`
SET `PId` = @ROOT_PID,
`PermissionCode` = '',
`Route` = '/xhs',
`Component` = NULL,
`Name` = '小红书',
`IsHidden` = 0,
`IsDeleted` = 0
WHERE `Id` = @XHS_PID;
-- 6 个子菜单挂到「小红书」下
UPDATE `menu`
SET `PId` = @XHS_PID,
`IsHidden` = 0,
`IsDeleted` = 0
WHERE `Id` IN (
'a1b2c3d4-e5f6-7890-abcd-ef1234567802', -- 启动服务
'a1b2c3d4-e5f6-7890-abcd-ef1234567803', -- 内容分析
'a1b2c3d4-e5f6-7890-abcd-ef1234567804', -- 爆款创作
'a1b2c3d4-e5f6-7890-abcd-ef1234567805', -- 发布记录
'a1b2c3d4-e5f6-7890-abcd-ef1234567806', -- 技能卡片
'a1b2c3d4-e5f6-7890-abcd-ef1234567807' -- 拟人设置
);
-- 诊断
SELECT `Name`, `Route`, `PId`, `PermissionCode`,
CASE
WHEN `Id` = @XHS_PID AND `PId` = @ROOT_PID AND (`PermissionCode` = '' OR `PermissionCode` IS NULL) THEN 'OK'
WHEN `PId` = @XHS_PID THEN 'OK-child'
ELSE 'CHECK'
END AS status
FROM `menu`
WHERE `Id` IN (
@XHS_PID,
'a1b2c3d4-e5f6-7890-abcd-ef1234567802',
'a1b2c3d4-e5f6-7890-abcd-ef1234567803',
'a1b2c3d4-e5f6-7890-abcd-ef1234567804',
'a1b2c3d4-e5f6-7890-abcd-ef1234567805',
'a1b2c3d4-e5f6-7890-abcd-ef1234567806',
'a1b2c3d4-e5f6-7890-abcd-ef1234567807'
)
ORDER BY `Order`;