20260919211702
This commit is contained in:
1 parent
f56e70b050
commit
f4bfc1ddfc
97 files changed
+6059
-1712
No files matched your search
+12
-14
@@ -205,7 +205,7 @@ create table dbo.s_relation (
|
||||
b_target_module_id varchar(50) not null, -- 目标模块
|
||||
b_target_field varchar(50) not null, -- 目标字段
|
||||
b_relation_type varchar(20) not null, -- one_to_one / one_to_many / many_to_one
|
||||
b_on_delete varchar(20) not null default 'none', -- 删除连带:none不连带 / cascade连带删除 / archive连带归档
|
||||
b_on_delete varchar(20) not null default 'restrict', -- 删除处置:restrict有外部引用即拒绝 / cascade连带删除 / none不处理不保护
|
||||
b_canuse tinyint not null default 1, -- 是否启用(0/1)
|
||||
b_xh int not null default 0, -- 显示顺序
|
||||
primary key (
|
||||
@@ -226,21 +226,19 @@ create index ix_s_relation_target
|
||||
GO
|
||||
|
||||
/* ============================================================================
|
||||
9.1 删除规则
|
||||
9.1 删除 SQL 规则
|
||||
|
||||
挂在模块(业务条件:勾条件 / 写 SQL)或模块关系(存在引用即拒绝删除)上的删除前规则。
|
||||
规则类型不单独存列,由 b_predicate 推断:空=引用规则;JSON=勾条件;其余=SQL 文本。
|
||||
b_scope_id 是挂载对象的业务键:模块=模块编码;关系=源模块|源字段|目标模块|目标字段。
|
||||
主键用雪花 id(新增时前端取号,与业务表一致):规则没有天然业务键,也不要求 IT 填编码。
|
||||
模块级“什么情况下不允许删除”的规则:b_sql 是只读查询,返回至少一行即拒绝本批删除。
|
||||
只服务模块删除(target=module);无模块的技术表走直接删除,不受本表约束。
|
||||
关系上的关联处置(含引用保护)由 s_relation.b_on_delete 表达,不再挂规则行。
|
||||
主键用雪花 id(新增时前端取号):规则没有天然业务键,也不要求 IT 填编码。
|
||||
============================================================================ */
|
||||
|
||||
create table dbo.s_rule (
|
||||
create table dbo.s_delete_rule (
|
||||
b_id bigint not null, -- 雪花主键(新增时前端经 /data/nextid 取号)
|
||||
b_scope_type varchar(20) not null, -- module / relation(挂载范围)
|
||||
b_scope_id varchar(250) not null, -- module=模块编码;relation=源模块|源字段|目标模块|目标字段
|
||||
b_hook varchar(30) not null, -- delete.pre(一期只做这个),save.pre 留位
|
||||
b_predicate nvarchar(max) null, -- 空=引用规则;JSON={"kind":"dsl","expr":…}=勾条件;其余=SQL 文本
|
||||
b_message nvarchar(500) null, -- 提示文案(写 SQL 必填;勾条件可空,引擎按条件自动生成)
|
||||
b_module_id varchar(50) not null, -- 规则所属数据模块编码(对应 s_module.b_id)
|
||||
b_sql nvarchar(max) not null, -- 只读查询 SQL,用 :ids 标记本次待删 ID 集合
|
||||
b_message nvarchar(500) null, -- 删除失败时的提示文案(第一阶段固定文案)
|
||||
b_canuse tinyint not null default 1, -- 是否启用(0/1)
|
||||
b_xh int not null default 0, -- 执行顺序(并列按 b_xh、b_id)
|
||||
b_created_by varchar(50) null, -- 审计列由服务端维护,配置界面不提交
|
||||
@@ -251,8 +249,8 @@ create table dbo.s_rule (
|
||||
);
|
||||
GO
|
||||
|
||||
create index ix_s_rule_scope
|
||||
on dbo.s_rule (b_scope_type, b_scope_id, b_hook, b_canuse, b_xh);
|
||||
create index ix_s_delete_rule_module
|
||||
on dbo.s_delete_rule (b_module_id, b_canuse, b_xh);
|
||||
GO
|
||||
|
||||
/* ============================================================================
|
||||
|
||||
Reference in new issue
Block a user