yunzer_go/server/database/check_role_permissions.sql
2025-11-06 15:56:29 +08:00

58 lines
1.2 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.

-- 检查角色权限数据
-- 查询角色ID为1的权限信息
-- 1. 查看角色基本信息
SELECT
role_id,
role_name,
menu_ids,
JSON_LENGTH(COALESCE(menu_ids, CAST('[]' AS JSON))) as menu_count,
tenant_id,
status
FROM yz_roles
WHERE role_id = 1;
-- 2. 查看所有角色的 menu_ids 字段
SELECT
role_id,
role_name,
menu_ids,
JSON_LENGTH(COALESCE(menu_ids, CAST('[]' AS JSON))) as menu_count
FROM yz_roles
WHERE delete_time IS NULL
ORDER BY role_id;
-- 3. 查看菜单表中有权限标识的菜单
SELECT
id,
name,
path,
permission,
menu_type,
parent_id
FROM yz_menus
WHERE delete_time IS NULL
AND permission IS NOT NULL
AND permission != ''
ORDER BY id
LIMIT 20;
-- 4. 如果 role_id=1 的 menu_ids 不为空,查看这些菜单的权限标识
-- 假设 menu_ids 是 [1,2,3],可以这样查询:
-- SELECT DISTINCT permission
-- FROM yz_menus
-- WHERE id IN (1,2,3)
-- AND delete_time IS NULL
-- AND permission IS NOT NULL
-- AND permission != '';
-- 5. 查看 menu_ids 字段的原始JSON值用于调试
SELECT
role_id,
role_name,
menu_ids,
CAST(menu_ids AS CHAR) as menu_ids_str
FROM yz_roles
WHERE role_id = 1;