diff --git a/backend/sql/mysql/init_snowflake_test_data.sql b/backend/sql/mysql/init_snowflake_test_data.sql index 1881a2db..b7c94355 100644 --- a/backend/sql/mysql/init_snowflake_test_data.sql +++ b/backend/sql/mysql/init_snowflake_test_data.sql @@ -103,16 +103,26 @@ values insert into sys_data_scope (id, name, status, created_time, updated_time) values -(2048601263901376512, '测试部门数据权限', 1, now(), null), -(2048601263968485376, '测试部门及以下数据权限', 1, now(), null); +(2048601263901376512, '本部门数据权限', 1, now(), null), +(2048601263968485376, '部门及以下数据权限', 1, now(), null), +(2048601263968485377, '仅本人数据权限', 1, now(), null), +(2048601263968485378, '全模型本部门数据权限', 1, now(), null), +(2048601263968485379, '排除超级管理员数据权限', 1, now(), null); insert into sys_data_rule (id, name, model, `column`, operator, expression, `value`, created_time, updated_time) values -(2048601264035594240, '部门名称等于测试', 'Dept', 'name', 1, 0, '测试', now(), null), -(2048601264102703104, '父部门 ID 等于 1', 'Dept', 'parent_id', 0, 0, '1', now(), null); +(2048601264035594240, '部门 ID 等于当前用户部门', 'Dept', '__dept_id__', 0, 0, '${dept_id}', now(), null), +(2048601264102703104, '部门名称等于测试', 'Dept', 'name', 1, 0, '测试', now(), null), +(2048601264102703105, '父部门 ID 等于测试部门 ID', 'Dept', 'parent_id', 0, 0, '1', now(), null), +(2048601264102703106, '创建者等于当前用户', '__ALL__', '__created_by__', 0, 0, '${user_id}', now(), null), +(2048601264102703107, '全模型部门 ID 等于当前用户部门', '__ALL__', '__dept_id__', 0, 0, '${dept_id}', now(), null), +(2048601264102703109, '用户非超级管理员', 'User', 'is_superuser', 0, 1, '1', now(), null); insert into sys_data_scope_rule (id, data_scope_id, data_rule_id) values (2048601264169811968, 2048601263901376512, 2048601264035594240), -(2048601264236920832, 2048601263968485376, 2048601264035594240), -(2048601264299835392, 2048601263968485376, 2048601264102703104); +(2048601264236920832, 2048601263968485376, 2048601264102703104), +(2048601264299835392, 2048601263968485376, 2048601264102703105), +(2048601264299835393, 2048601263968485377, 2048601264102703106), +(2048601264299835394, 2048601263968485378, 2048601264102703107), +(2048601264299835395, 2048601263968485379, 2048601264102703109); diff --git a/backend/sql/mysql/init_test_data.sql b/backend/sql/mysql/init_test_data.sql index 245e8891..b93b9282 100644 --- a/backend/sql/mysql/init_test_data.sql +++ b/backend/sql/mysql/init_test_data.sql @@ -103,13 +103,20 @@ values insert into sys_data_scope (id, name, status, created_time, updated_time) values -(1, '测试部门数据权限', 1, now(), null), -(2, '测试部门及以下数据权限', 1, now(), null); +(1, '本部门数据权限', 1, now(), null), +(2, '部门及以下数据权限', 1, now(), null), +(3, '仅本人数据权限', 1, now(), null), +(4, '全模型本部门数据权限', 1, now(), null), +(5, '排除超级管理员数据权限', 1, now(), null); insert into sys_data_rule (id, name, model, `column`, operator, expression, `value`, created_time, updated_time) values -(1, '部门名称等于测试', 'Dept', 'name', 1, 0, '测试', now(), null), -(2, '父部门 ID 等于 1', 'Dept', 'parent_id', 0, 0, '1', now(), null); +(1, '部门 ID 等于当前用户部门', 'Dept', '__dept_id__', 0, 0, '${dept_id}', now(), null), +(2, '部门名称等于测试', 'Dept', 'name', 1, 0, '测试', now(), null), +(3, '父部门 ID 等于测试部门 ID', 'Dept', 'parent_id', 0, 0, '1', now(), null), +(4, '创建者等于当前用户', '__ALL__', '__created_by__', 0, 0, '${user_id}', now(), null), +(5, '全模型部门 ID 等于当前用户部门', '__ALL__', '__dept_id__', 0, 0, '${dept_id}', now(), null), +(6, '用户非超级管理员', 'User', 'is_superuser', 0, 1, '1', now(), null); insert into sys_role_data_scope (id, role_id, data_scope_id) values @@ -119,5 +126,8 @@ values insert into sys_data_scope_rule (id, data_scope_id, data_rule_id) values (1, 1, 1), -(2, 2, 1), -(3, 2, 2); +(2, 2, 2), +(3, 2, 3), +(4, 3, 4), +(5, 4, 5), +(6, 5, 6); diff --git a/backend/sql/postgresql/init_snowflake_test_data.sql b/backend/sql/postgresql/init_snowflake_test_data.sql index 5e02f1d7..0f8114da 100644 --- a/backend/sql/postgresql/init_snowflake_test_data.sql +++ b/backend/sql/postgresql/init_snowflake_test_data.sql @@ -103,16 +103,26 @@ values insert into sys_data_scope (id, name, status, created_time, updated_time) values -(2048601269806956544, '测试部门数据权限', 1, now(), null), -(2048601269869871104, '测试部门及以下数据权限', 1, now(), null); +(2048601269806956544, '本部门数据权限', 1, now(), null), +(2048601269869871104, '部门及以下数据权限', 1, now(), null), +(2048601269869871105, '仅本人数据权限', 1, now(), null), +(2048601269869871106, '全模型本部门数据权限', 1, now(), null), +(2048601269869871107, '排除超级管理员数据权限', 1, now(), null); insert into sys_data_rule (id, name, model, "column", operator, expression, "value", created_time, updated_time) values -(2048601269932785664, '部门名称等于测试', 'Dept', 'name', 1, 0, '测试', now(), null), -(2048601269999894528, '父部门 ID 等于 1', 'Dept', 'parent_id', 0, 0, '1', now(), null); +(2048601269932785664, '部门 ID 等于当前用户部门', 'Dept', '__dept_id__', 0, 0, '${dept_id}', now(), null), +(2048601269999894528, '部门名称等于测试', 'Dept', 'name', 1, 0, '测试', now(), null), +(2048601269999894529, '父部门 ID 等于测试部门 ID', 'Dept', 'parent_id', 0, 0, '1', now(), null), +(2048601269999894530, '创建者等于当前用户', '__ALL__', '__created_by__', 0, 0, '${user_id}', now(), null), +(2048601269999894531, '全模型部门 ID 等于当前用户部门', '__ALL__', '__dept_id__', 0, 0, '${dept_id}', now(), null), +(2048601269999894533, '用户非超级管理员', 'User', 'is_superuser', 0, 1, '1', now(), null); insert into sys_data_scope_rule (id, data_scope_id, data_rule_id) values (2048601270062809088, 2048601269806956544, 2048601269932785664), -(2048601270125723648, 2048601269869871104, 2048601269932785664), -(2048601270192832512, 2048601269869871104, 2048601269999894528); +(2048601270125723648, 2048601269869871104, 2048601269999894528), +(2048601270192832512, 2048601269869871104, 2048601269999894529), +(2048601270192832513, 2048601269869871105, 2048601269999894530), +(2048601270192832514, 2048601269869871106, 2048601269999894531), +(2048601270192832515, 2048601269869871107, 2048601269999894533); diff --git a/backend/sql/postgresql/init_test_data.sql b/backend/sql/postgresql/init_test_data.sql index a18da297..a5810dea 100644 --- a/backend/sql/postgresql/init_test_data.sql +++ b/backend/sql/postgresql/init_test_data.sql @@ -103,13 +103,20 @@ values insert into sys_data_scope (id, name, status, created_time, updated_time) values -(1, '测试部门数据权限', 1, now(), null), -(2, '测试部门及以下数据权限', 1, now(), null); +(1, '本部门数据权限', 1, now(), null), +(2, '测试部门及以下数据权限', 1, now(), null), +(3, '仅本人数据权限', 1, now(), null), +(4, '全模型本部门数据权限', 1, now(), null), +(5, '排除超级管理员数据权限', 1, now(), null); insert into sys_data_rule (id, name, model, "column", operator, expression, "value", created_time, updated_time) values -(1, '部门名称等于测试', 'Dept', 'name', 1, 0, '测试', now(), null), -(2, '父部门 ID 等于 1', 'Dept', 'parent_id', 0, 0, '1', now(), null); +(1, '部门 ID 等于当前用户部门', 'Dept', '__dept_id__', 0, 0, '${dept_id}', now(), null), +(2, '部门名称等于测试', 'Dept', 'name', 1, 0, '测试', now(), null), +(3, '父部门 ID 等于测试部门 ID', 'Dept', 'parent_id', 0, 0, '1', now(), null), +(4, '创建者等于当前用户', '__ALL__', '__created_by__', 0, 0, '${user_id}', now(), null), +(5, '全模型部门 ID 等于当前用户部门', '__ALL__', '__dept_id__', 0, 0, '${dept_id}', now(), null), +(6, '用户非超级管理员', 'User', 'is_superuser', 0, 1, '1', now(), null); insert into sys_role_data_scope (id, role_id, data_scope_id) values @@ -119,8 +126,11 @@ values insert into sys_data_scope_rule (id, data_scope_id, data_rule_id) values (1, 1, 1), -(2, 2, 1), -(3, 2, 2); +(2, 2, 2), +(3, 2, 3), +(4, 3, 4), +(5, 4, 5), +(6, 5, 6); select setval(pg_get_serial_sequence('sys_dept', 'id'),coalesce(max(id), 0) + 1, true) from sys_dept; select setval(pg_get_serial_sequence('sys_menu', 'id'),coalesce(max(id), 0) + 1, true) from sys_menu;