Files
workspace/code/fms/sql/fms_menu_power.sql
T
2026-09-20 22:05:20 +08:00

47 lines
2.0 KiB
Transact-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.
/* ============================================================================
FMS 菜单入口权限点(s_power,b_object_type = 'menu')
背景:设计文档 §14.1 与《FMS模块关系与权限边界重构计划》§3.2 规定
menu.* 控制「能否进入菜单页面」,但此前没有任何地方生成它 —— s_power 里
menu 类型权限点为 0 行,「用户管理 → 分配权限 → 功能权限」因此无法给菜单授权。
规则:每个 page / external 菜单一行 menu.{菜单编码},b_action = 'access'。
directory 是纯导航分组,不设权限点(侧栏按子菜单裁剪)。
落库后由「菜单管理」在保存 / 删除菜单时自动维护(新增自动派生、删除自动清理),
本脚本只在首次上线或历史数据修补时执行;可重复执行(幂等,已存在的跳过)。
============================================================================ */
insert into dbo.s_power
(b_id, b_name, b_i18n, b_type, b_object_type, b_object_id, b_action, b_canuse, b_xh, b_bz)
select 'menu.' + m.b_id,
m.b_name,
'menu.' + m.b_id,
'menu',
'menu',
m.b_id,
'access',
1,
m.b_xh,
N'菜单入口权限(菜单管理自动派生)'
from dbo.s_menu m
where m.b_menu_type in ('page', 'external')
and not exists (
select 1 from dbo.s_power p
where p.b_object_type = 'menu' and p.b_object_id = m.b_id
);
GO
/* ----------------------------------------------------------------------------
自检
---------------------------------------------------------------------------- */
select N'可授权菜单数(page + external)' as 项, count(*) as 行数
from dbo.s_menu where b_menu_type in ('page', 'external')
union all
select N's_power(menu.*) 行数', count(*)
from dbo.s_power where b_object_type = 'menu'
union all
select N'其中启用', count(*)
from dbo.s_power where b_object_type = 'menu' and b_canuse = 1;
GO