20260920173439
This commit is contained in:
1 parent
f4bfc1ddfc
commit
6f03d92425
174 files changed
+23490
-157
No files matched your search
@@ -0,0 +1,119 @@
|
||||
/* ============================================================================
|
||||
FMS 模拟数据脚本 — 用户功能权限(s_power / s_user_power)
|
||||
|
||||
用途:为「用户管理 → 分配权限 → 功能权限」抽屉准备可演示的数据。
|
||||
现状(执行前):s_power 仅 2 行、s_user_power 0 行,权限抽屉打开是空的。
|
||||
|
||||
本脚本做两件事:
|
||||
1. 为若干启用模块补齐标准权限点(s_power);
|
||||
2. 给演示账号 001 写入一批初始授权(s_user_power)。
|
||||
|
||||
权限编码规则(见《FMS新系统核心表结构设计》§14.1,前端 utils.buildPowerCode 同一口径):
|
||||
模块使用权限 module.{模块编码} b_type='module' b_action='access'
|
||||
业务动作权限 action.{模块编码}.{动作} b_type='action' b_action=动作名
|
||||
|
||||
可重复执行:先按 b_object_id 清理本脚本负责的模块,再重建。
|
||||
============================================================================ */
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
1. 清理本脚本负责的权限点(只动本脚本登记的模块,不影响 s_i18n_type 等既有行)
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
delete from dbo.s_power
|
||||
where b_object_type = 'module'
|
||||
and b_object_id in (
|
||||
'v_b_othercompany', 'v_b_contact',
|
||||
'b_money', 'b_feetype', 'b_port', 'b_oceanline', 'b_vessel', 'b_depot'
|
||||
);
|
||||
GO
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
2. 模块使用权限 point:module.{模块编码}
|
||||
|
||||
b_name 用模块名,前端展示时优先取 s_i18n,这里给中文兜底。
|
||||
b_i18n 用 module.{模块编码},与模块名称共用资源键(见设计文档 §11)。
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
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)
|
||||
values
|
||||
('module.v_b_othercompany', N'合作伙伴', 'module.v_b_othercompany', 'module', 'module', 'v_b_othercompany', 'access', 1, 10, N'模拟数据:模块使用权限'),
|
||||
('module.v_b_contact', N'联系人', 'module.v_b_contact', 'module', 'module', 'v_b_contact', 'access', 1, 20, N'模拟数据:模块使用权限'),
|
||||
('module.b_money', N'币种', 'module.b_money', 'module', 'module', 'b_money', 'access', 1, 30, N'模拟数据:模块使用权限'),
|
||||
('module.b_feetype', N'费用类别', 'module.b_feetype', 'module', 'module', 'b_feetype', 'access', 1, 40, N'模拟数据:模块使用权限'),
|
||||
('module.b_port', N'港口', 'module.b_port', 'module', 'module', 'b_port', 'access', 1, 50, N'模拟数据:模块使用权限'),
|
||||
('module.b_oceanline', N'航线', 'module.b_oceanline', 'module', 'module', 'b_oceanline', 'access', 1, 60, N'模拟数据:模块使用权限'),
|
||||
('module.b_vessel', N'船名船次', 'module.b_vessel', 'module', 'module', 'b_vessel', 'access', 1, 70, N'模拟数据:模块使用权限'),
|
||||
('module.b_depot', N'仓库', 'module.b_depot', 'module', 'module', 'b_depot', 'access', 1, 80, N'模拟数据:模块使用权限');
|
||||
GO
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
3. 业务动作权限:action.{模块编码}.{动作}
|
||||
|
||||
只为「主数据」类模块配业务动作(字典类模块通常只有使用权限)。
|
||||
合作伙伴与联系人是有状态的业务对象,给完整的新增/修改/删除/审核。
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
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)
|
||||
values
|
||||
-- 合作伙伴:新增 / 修改 / 删除 / 审核
|
||||
('action.v_b_othercompany.create', N'新增', 'action.insert', 'action', 'module', 'v_b_othercompany', 'create', 1, 110, N'模拟数据:业务动作权限'),
|
||||
('action.v_b_othercompany.update', N'修改', 'action.update', 'action', 'module', 'v_b_othercompany', 'update', 1, 120, N'模拟数据:业务动作权限'),
|
||||
('action.v_b_othercompany.delete', N'删除', 'action.delete', 'action', 'module', 'v_b_othercompany', 'delete', 1, 130, N'模拟数据:业务动作权限'),
|
||||
('action.v_b_othercompany.audit', N'审核', 'action.audit', 'action', 'module', 'v_b_othercompany', 'audit', 1, 140, N'模拟数据:业务动作权限'),
|
||||
-- 联系人:新增 / 修改 / 删除
|
||||
('action.v_b_contact.create', N'新增', 'action.insert', 'action', 'module', 'v_b_contact', 'create', 1, 150, N'模拟数据:业务动作权限'),
|
||||
('action.v_b_contact.update', N'修改', 'action.update', 'action', 'module', 'v_b_contact', 'update', 1, 160, N'模拟数据:业务动作权限'),
|
||||
('action.v_b_contact.delete', N'删除', 'action.delete', 'action', 'module', 'v_b_contact', 'delete', 1, 170, N'模拟数据:业务动作权限'),
|
||||
-- 基础字典:新增 / 修改 / 删除(字典维护是同一类操作)
|
||||
('action.b_money.create', N'新增', 'action.insert', 'action', 'module', 'b_money', 'create', 1, 180, N'模拟数据:业务动作权限'),
|
||||
('action.b_money.update', N'修改', 'action.update', 'action', 'module', 'b_money', 'update', 1, 190, N'模拟数据:业务动作权限'),
|
||||
('action.b_feetype.create', N'新增', 'action.insert', 'action', 'module', 'b_feetype', 'create', 1, 200, N'模拟数据:业务动作权限'),
|
||||
('action.b_feetype.update', N'修改', 'action.update', 'action', 'module', 'b_feetype', 'update', 1, 210, N'模拟数据:业务动作权限'),
|
||||
('action.b_port.create', N'新增', 'action.insert', 'action', 'module', 'b_port', 'create', 1, 220, N'模拟数据:业务动作权限'),
|
||||
('action.b_port.update', N'修改', 'action.update', 'action', 'module', 'b_port', 'update', 1, 230, N'模拟数据:业务动作权限');
|
||||
GO
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
4. 演示授权:给账号 001 写入初始权限
|
||||
|
||||
模拟一个「基础资料维护员」:能维护币种 / 港口 / 费用类别,但只看合作伙伴、不能改。
|
||||
取消勾选 = 删行(s_user_power 是「拥有」语义,不置 b_canuse = 0)。
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
delete from dbo.s_user_power where b_user_id = '001';
|
||||
GO
|
||||
|
||||
insert into dbo.s_user_power (b_user_id, b_power_id, b_canuse, b_created_by, b_created_at)
|
||||
values
|
||||
-- 合作伙伴:只读(有使用权限,无任何业务动作)
|
||||
('001', 'module.v_b_othercompany', 1, 'system', sysdatetime()),
|
||||
-- 联系人:可新增 / 修改
|
||||
('001', 'module.v_b_contact', 1, 'system', sysdatetime()),
|
||||
('001', 'action.v_b_contact.create', 1, 'system', sysdatetime()),
|
||||
('001', 'action.v_b_contact.update', 1, 'system', sysdatetime()),
|
||||
-- 基础字典:币种 / 港口 / 费用类别 —— 完整维护
|
||||
('001', 'module.b_money', 1, 'system', sysdatetime()),
|
||||
('001', 'action.b_money.create', 1, 'system', sysdatetime()),
|
||||
('001', 'action.b_money.update', 1, 'system', sysdatetime()),
|
||||
('001', 'module.b_feetype', 1, 'system', sysdatetime()),
|
||||
('001', 'action.b_feetype.create', 1, 'system', sysdatetime()),
|
||||
('001', 'action.b_feetype.update', 1, 'system', sysdatetime()),
|
||||
('001', 'module.b_port', 1, 'system', sysdatetime()),
|
||||
('001', 'action.b_port.create', 1, 'system', sysdatetime()),
|
||||
('001', 'action.b_port.update', 1, 'system', sysdatetime());
|
||||
GO
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
5. 自检
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
select N's_power 总行数' as 项, count(*) as 行数 from dbo.s_power
|
||||
union all
|
||||
select N's_power 模拟行数', count(*) from dbo.s_power where b_bz like N'模拟数据%'
|
||||
union all
|
||||
select N' └ module 类型', count(*) from dbo.s_power where b_type = 'module'
|
||||
union all
|
||||
select N' └ action 类型', count(*) from dbo.s_power where b_type = 'action'
|
||||
union all
|
||||
select N's_user_power(001)', count(*) from dbo.s_user_power where b_user_id = '001';
|
||||
GO
|
||||
Reference in new issue
Block a user